#include <bits/stdc++.h>
using namespace std;
int MAX(int a, int b) { return a < b ? b : a; }
int MIN(int a, int b) { return a > b ? b : a; }
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
bool is_letter_s(char a) {
  if ((a >= 'a') && (a <= 'z'))
    return true;
  else
    return false;
}
bool is_letter_b(char a) {
  if ((a >= 'A') && (a <= 'Z'))
    return true;
  else
    return false;
}
bool is_number(char a) {
  if ((a >= '0') && (a <= '9'))
    return true;
  else
    return false;
}
int main() {
  int n;
  cin >> n;
  int a[110];
  int max = -1000;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 1) cnt++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      int cnt = 0;
      for (int k = i; k <= j; k++)
        if (a[k] == 0)
          cnt++;
        else
          cnt--;
      max = MAX(max, cnt);
    }
  }
  cout << max + cnt;
  return 0;
}
