#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  bool check;
  int n, ans = -(int)1e9, now = 0;
  cin >> n;
  vector<int> list(n);
  for (int i = 0; i < n; i++) {
    cin >> list[i];
    now += list[i];
  }
  ans = max(ans, now);
  if (now == n)
    check = 1;
  else
    check = 0;
  for (int i = n - 1; i >= 0; i--)
    for (int k = 0; k < n; k++) {
      now = 0;
      for (int j = 0; j < n; j++) {
        if (j >= k && j <= i) {
          if (list[j] == 0) now++;
        } else
          now += list[j];
      }
      ans = max(ans, now);
    }
  if (check == 1)
    cout << ans - 1 << endl;
  else
    cout << ans << endl;
}
