#include <bits/stdc++.h>
int main() {
  int i, j, n, a[110];
  scanf("%d", &n);
  int count = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", a + i);
    if (a[i]) count++;
  }
  int max = count;
  int temp;
  for (i = 0; i < n; i++) {
    temp = count;
    for (j = i; j < n; j++) {
      if (a[j] == 0)
        temp++;
      else
        temp--;
      max = temp > max ? temp : max;
    }
  }
  if (count == max)
    printf("%d\n", max - 1);
  else
    printf("%d\n", max);
  return 0;
}
