#include <bits/stdc++.h>
using namespace std;
bool foundZero = false;
int findMaxOneCount(bool arr[], int n) {
  int max_diff = 0;
  int orig_one_count = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 1)
      orig_one_count++;
    else
      foundZero = true;
    int count1 = 0, count0 = 0;
    for (int j = i; j < n; j++) {
      (arr[j] == 1) ? count1++ : count0++;
      max_diff = max(max_diff, count0 - count1);
    }
  }
  return orig_one_count + max_diff;
}
int main() {
  int n;
  bool arr[100], x;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    arr[i] = x;
  }
  int maxNumOfOne = findMaxOneCount(arr, n);
  if (n == maxNumOfOne && !foundZero) {
    cout << maxNumOfOne - 1 << endl;
  } else {
    cout << maxNumOfOne << endl;
  }
}
