#include <bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main() {
  int n;
  arr[0] = 0;
  while (cin >> n) {
    for (int i = 1; i <= n; i++) {
      int k;
      scanf("%d", &k);
      arr[i] = arr[i - 1] + k;
    }
    map<int, int> ma;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      if (ma[arr[i]] == 0)
        ma[arr[i]] = i;
      else {
        ans = max(ans, i - ma[arr[i]]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
