#include <bits/stdc++.h>
using namespace std;
int n, t, b[101], s = 0;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> t;
    s += t;
    t ? t = -1 : t = 1;
    b[i] = max(t, b[i - 1] + t);
    b[0] = max(b[0], b[i]);
  }
  cout << b[0] + s - (s == n);
}
