#include<bits/stdc++.h>
using namespace std;
int a[10003], f[10003];
int main()
{
int n, i;
cin >> n;
int a[n+1];
for(i=1;i<=n;i++)
cin >> a[i];
for(i=1;i<10003;i++)
f[i] = -3;
f[0] = 0;
int t = 0, l = 0, r = 0;
for(i=1;i<=n;i++)
{
if(a[i]%n == 0)
{
cout << 1 << "\n";
cout << a[i] << "\n";
return 0;
}
t = (t+a[i])%n;
if(f[t] == -3)
f[t] = i;
else
{
l = f[t];
r = i;
break;
}
}
cout << r-l << "\n";
for(i=l+1;i<=r;i++)
cout << a[i] << "\n";
return 0;
}
Comments
Post a Comment