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