#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
  }
  int s = 0;
  int arr[n + 1], max;
  max = INT_MIN;
  memset(arr, 0, sizeof(arr));
  for (int i = 1; i < n + 1; i++) {
    if (a[i] == 1) {
      arr[i] = arr[i - 1] + 1;
    } else {
      arr[i] = 0;
    }
    if (arr[i] > max) {
      max = arr[i];
    }
  }
  if (arr[n] != 0) {
    int j = 1;
    while (arr[j] != 0) {
      arr[n]++;
      j++;
    }
    if (arr[n] > max) {
      max = arr[n];
    }
  }
  cout << max;
  return 0;
}
