#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int mem[102];
  mem[0] = 0;
  int original[102], maxOnes = 0, n;
  cin >> (n);
  for (int i(1); i < n + 1; i++) {
    cin >> (original[i]);
    mem[i] = (original[i] == 1) ? mem[i - 1] + 1 : mem[i - 1];
  }
  for (int i(1); i < n + 1; i++) {
    for (int j(i); j < n + 1; j++) {
      int nbrDeUn = mem[n];
      for (int k(i); k < j + 1; k++) {
        if ((1 - original[k]) == 1)
          nbrDeUn++;
        else
          nbrDeUn--;
      }
      maxOnes = max(maxOnes, nbrDeUn);
    }
  }
  cout << (maxOnes);
  return 0;
}
