#include <bits/stdc++.h>
using namespace std;
const long long LLINF = LLONG_MAX - 7;
const int INF = INT_MAX - 7;
const int MAX = 100 + 7;
const int MOD = 1e9 + 7;
int n, a[MAX], dp[MAX], cnt1, cnt0, mx = -1;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i]) {
      cnt1++;
      if (cnt0) cnt0--;
    } else {
      cnt0++;
      mx = max(mx, cnt0);
    }
  }
  cout << mx + cnt1;
  return EXIT_SUCCESS;
}
