#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  long long a[110], ans = 0;
  scanf("%lld", &n);
  for (long long i = 0; i < n; i++) scanf("%lld", a + i), ans += a[i];
  long long cur, mx = 0;
  for (long long i = 0; i <= n - 1; i++) {
    cur = 0;
    for (long long j = i; j <= n - 1; j++) {
      if (a[j])
        cur--;
      else
        cur++;
      mx = max(cur, mx);
    }
  }
  ans += mx;
  if (mx == 0) ans--;
  printf("%lld\n", ans);
  return 0;
}
