#include <bits/stdc++.h>
using namespace std;
int n, s[110];
int cal(int i, int j) {
  int res = 0;
  for (int k = 1; k < i; ++k) res += s[k];
  for (int k = j + 1; k <= n; ++k) res += s[k];
  for (int k = i; k <= j; ++k) res += (1 - s[k]);
  return res;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> s[i];
  int res = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = i; j <= n; ++j) res = max(res, cal(i, j));
  cout << res << endl;
  return 0;
}
