#include <bits/stdc++.h>
using namespace std;
void solve();
vector<int> coins;
int main(int argc, char const *argv[]) { solve(); }
int n;
int arr[100];
int memo[100][100];
int total = 0;
int flip(int i, int j) {
  if (i > j) return -1;
  if (i == j) {
    return total - arr[j] + !arr[i];
  }
  if (memo[i][j] != -1) return memo[i][j];
  return memo[i][j] = flip(i, j - 1) - arr[j] + !arr[j];
}
void solve() {
  scanf("%d", &n);
  memset(memo, -1, sizeof memo);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    total += arr[i];
  }
  int ones = 0;
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) {
      ones = max(ones, flip(i, j));
    }
  printf("%d\n", ones);
}
