#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, mx = -1;
  cin >> n;
  long long int ara[n];
  for (long long int i = 0; i < n; i++) cin >> ara[i];
  for (long long int i = 0; i < n; i++) {
    for (long long int j = i; j < n; j++) {
      long long int b = 0, ans = 0;
      for (long long int x = 0; x < i; x++)
        if (ara[x] == 1) ans++;
      for (long long int k = i; k <= j; k++) {
        if (ara[k] == 0) b++;
      }
      for (long long int x = j + 1; x < n; x++)
        if (ara[x] == 1) ans++;
      ans += b;
      mx = max(mx, ans);
    }
  }
  cout << mx << endl;
  return 0;
}
