#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  long long int pre = 0;
  int counter = 0;
  while (counter < n && arr[counter] != 0) {
    pre++;
    counter++;
  }
  long long int post = 0;
  counter = n - 1;
  while (counter >= 0 && arr[counter] != 0) {
    counter--;
    post++;
  }
  counter = 0;
  long long int mx = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 0) {
      if (mx < counter) mx = counter;
      counter = 0;
    } else {
      counter++;
    }
  }
  if (counter > mx) mx = counter;
  if (mx < pre + post) mx = pre + post;
  cout << mx << '\n';
  return 0;
}
