import java.util.Scanner;
import java.util.Arrays;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
InputReader s = new InputReader();
int N = s.nextInt();
int[] presum = new int[N+1];
presum[0] = 0;
int count = 0;
for (int i = 0; i<N; i++) {
presum[i+1] = presum[i]+s.nextInt();
}
for (int i = 0; i<N; i++) {
for (int j = i+1; j<N+1; j++) {
if ((presum[j]-presum[i])%7 == 0 && j-i>count) {
count = j-i;
}
}
}
System.out.print(count);
}
}
class InputReader {
StreamTokenizer st=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
public int nextInt() throws Exception{
st.nextToken();
return (int)st.nval;
}
public long nextLong() throws Exception{
st.nextToken();
return (long)st.nval;
}
}