#include <bits/stdc++.h>
using namespace std;
vector<int> s;
int n, k, ans, a;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> k;
    s.push_back(k);
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (k < i) {
          a += s.at(k) == 1;
        } else if (k > j) {
          a += s.at(k) == 1;
        } else {
          a += s.at(k) == 0;
        }
      }
      ans = max(ans, a);
      a = 0;
    }
  }
  cout << ans;
  return 0;
}
