#include<bits/stdc++.h> #define int long long #define endl '\n' usingnamespace std;
signedmain(){ ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); int n; cin >> n; vector<int> a(n + 1); for(int i = 1; i <= n ;i++){ cin >> a[i]; } auto b = a; partial_sum(a.begin(),a.end(),b.begin()); unordered_map<int,int> m; m[0] = 0; int sum = 0; int re = 0; for(int i = 1; i <= n ;i++){ sum += a[i]; int mod = sum % 7; if(m.count(mod)){ re = max(re, i - m[mod]); }else{ m[mod] = i; } } cout << re << endl; return0; }