#include <bits/stdc++.h>
using namespace std;
const int MAXn = 1e2 + 10;
bool a[MAXn];
int n, x, sum[MAXn], mx = -1;
signed main() {
  cin >> n >> a[1];
  sum[1] = a[1];
  for (int i = 2; i < n + 1; ++i) cin >> a[i], sum[i] = sum[i - 1] + a[i];
  for (int i = 1; i < n + 1; ++i) {
    for (int j = i; j < n + 1; ++j) {
      x = sum[j] - sum[i - 1];
      mx = max(mx, (j - i + 1) - x + sum[i - 1] + sum[n] - sum[j]);
    }
  }
  return cout << (mx == -1 ? (1 ^ a[1]) : mx) << endl, 0;
}
