#include <bits/stdc++.h>
using namespace std;
int main() {
  int T = 1;
  while (T--) {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (size_t iai = 0; iai < a.size(); iai++) {
      std::cin >> a[iai];
    };
    int ans = 0;
    int temp = 0;
    for (int i = 0; i < n; ++i) {
      if (a[i] == 1) {
        temp++;
      } else {
        ans = max(ans, temp);
        temp = 0;
      }
    }
    if (temp != 0 && temp != n) {
      int q = 0;
      while (a[q] == 1) {
        temp++;
        q++;
      }
    }
    ans = max(ans, temp);
    std::cout << ans << std::endl;
  }
  return 0;
}
