#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int max = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      cnt = 0;
      for (int k = i; k <= j; k++) {
        if (a[k] == 0) {
          cnt++;
        } else if (a[k] == 1) {
          cnt--;
        }
      }
      for (int k = 0; k < n; k++) {
        if (a[k] == 1) {
          cnt++;
        }
      }
      if (cnt > max) {
        max = cnt;
      }
    }
  }
  cout << max << endl;
  int op;
  cin >> op;
  return 0;
}
