#include <bits/stdc++.h>
using namespace std;
int n, a[1001], cnt, ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      cnt = 0;
      for (int k = 1; k <= n; ++k) {
        if (k >= i && k <= j) {
          if (a[k] == 0) ++cnt;
        }
        if (k < i || k > j) {
          if (a[k] == 1) ++cnt;
        }
      }
      ans = max(cnt, ans);
    }
  }
  cout << ans;
}
