#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  string s = "";
  int m = n;
  while (n--) {
    char bin;
    cin >> bin;
    s += bin;
  }
  int check = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '1') check++;
  }
  if (check == m) {
    cout << check - 1;
    return 0;
  }
  if (m == 1) {
    cout << 1;
    return 0;
  }
  int maxi = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '0') {
      string clone = s;
      clone[i] = '1';
      for (int j = i + 1; j < s.length(); j++) {
        if (clone[j] == '1')
          clone[j] = '0';
        else if (clone[j] == '0') {
          clone[j] = '1';
        }
        int ans = 0;
        for (int k = 0; k < s.length(); k++) {
          if (clone[k] == '1') ans++;
          maxi = max(maxi, ans);
        }
      }
    }
  }
  cout << maxi;
}
