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