#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int arr[n];
  int unos = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    if (arr[i]) unos++;
  }
  int fin = 0;
  for (int i = 0; i < n; i++) {
    int total = unos;
    for (int j = i; j < n; j++) {
      if (arr[j])
        total--;
      else
        total++;
      fin = max(fin, total);
    }
  }
  printf("%d", fin);
  return 0;
}
