#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, i, j, n, sum, temp = 0, count = 0;
  cin >> n;
  int arr[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] == 1) {
      count++;
    }
    if (arr[i] == 0) {
      temp = max(temp, count);
      count = 0;
    }
  }
  count = 0;
  for (i = 0; i < n; i++) {
    if (arr[i] == 0)
      break;
    else
      count++;
  }
  for (i = n - 1; i >= 0; i--) {
    if (arr[i] == 0)
      break;
    else
      count++;
  }
  temp = max(temp, count);
  cout << temp;
}
