#include <bits/stdc++.h>
using namespace std;
int n, s, mx = 1 << 31, l, a[100];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i], s += a[i] == 1 ? 1 : 0;
  for (int i = 0; i < n; ++i)
    for (int j = i; j < n; ++j) {
      l = 0;
      for (int k = i; k <= j; ++k) l += 1 - a[k] == 1 ? 1 : -1;
      mx = max(mx, s + l);
    }
  cout << mx << "\n";
  return 0;
}
