#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
void setIO(string name = "") {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  if ((int)(name).size()) {
    freopen((name + ".in").c_str(), "r", stdin);
    freopen((name + ".out").c_str(), "w", stdout);
  }
}
int n;
int a[105];
int main() {
  setIO();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    a[i] += a[i - 1];
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      int seg = a[j] - a[i - 1];
      ans = max(ans, a[n] - seg + (j - i + 1) - seg);
    }
  }
  cout << ans << '\n';
}
