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