#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int N, er[maxn], ans, sum, flag;
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", &er[i]);
  for (int i = 1; i <= N; sum += er[i], i++)
    for (int j = i, k = 0; j <= N; j++) {
      if (er[j])
        k--;
      else
        k++;
      if (!flag || k > ans) ans = k, flag = 1;
    }
  printf("%d\n", ans + sum);
  return 0;
}
