Hello guys!

I've tried to solve the next problem:

For a sequence of natural numbers n you must establish the maximum number of elements of the sequence whose sum divides 3 and the items that don't belong the sum.

So,I need a variable n(for the number of numbers that will be read),nr(for the number I read at the current step),i,s3(that is initially 0) and a counter that counts the maximum items of the sequence whose sum divides 3.

How should I do it?

Code:

int n,i,nr,s3 = 0,k3 = 1;
cin >> n;
for (i = 1;i <= n;i++) {
cin >> nr;
s = s+nr;
if (s % 3 == 0) break; // What should I do here ??
}

Thanks in advance !!