#include <bits/stdc++.h>
using namespace std;
int n, ans;
vector<int> answers, arr;
void solve(int idx, int jdx) {
  if (jdx == n) {
    return;
  }
  int k = idx, l = jdx, ans = 0;
  for (int i = 0; i < arr.size(); i++) {
    if ((i <= l && i >= k && l > k) || (l < k && i <= k && i >= l)) {
      if (arr[i] == 0) ans++;
    } else if (l == k)
      continue;
    else {
      if (arr[i] == 1) ans++;
    }
  }
  answers.push_back(ans);
  solve(idx, jdx + 1);
}
int main() {
  int c = 0, g = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    arr.push_back(x);
    if (x == 1) c++;
    if (x == 0) g++;
  }
  if (c == n) {
    cout << n - 1;
    return 0;
  }
  if (g == n) {
    cout << g;
    return 0;
  }
  if (n == 1) {
    if (arr[0] == 0)
      cout << 1;
    else
      cout << 0;
    return 0;
  }
  for (int i = 0; i < arr.size(); i++) solve(i, 0);
  sort(answers.begin(), answers.end());
  cout << answers[answers.size() - 1];
  return 0;
}
