#include <bits/stdc++.h>
using namespace std;
int values[100];
int sum[100];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int t;
    scanf("%d", &t);
    values[i] = t;
    if (i > 0) {
      sum[i] = sum[i - 1] + t;
    } else {
      sum[0] = t;
    }
  }
  int best = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      int before = sum[i] - values[i];
      int after = sum[n - 1] - sum[j];
      int between = sum[j] - sum[i] + values[i];
      between = (j - i + 1) - between;
      best = max(best, before + after + between);
    }
  }
  printf("%d\n", best);
  return 0;
}
