#include <bits/stdc++.h>
using namespace std;
long long int diff(long long int x, long long int y) {
  if (x > y) {
    return x - y;
  } else {
    return y - x;
  }
}
int main() {
  long long int n;
  cin >> n;
  long long int arr[n];
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long int count = 0;
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    if (arr[i] == 1) {
      count++;
      if (count > ans) {
        ans = count;
      }
    } else {
      count = 0;
    }
  }
  if (count != 0) {
    for (int i = 0; i < n; i++) {
      if (arr[i] == 1) {
        count++;
        if (count > ans) {
          ans = count;
        }
      } else {
        break;
      }
    }
  }
  cout << ans;
  return 0;
}
