#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 mx = INT_MIN;
  for (int i = 0; i < n; i++) {
    int one = 0, zero = 0;
    for (int j = i; j < n; j++) {
      if (a[j] == 1) {
        one++;
      } else {
        zero++;
      }
      if (zero > one) {
        mx = max(mx, zero - one);
      }
    }
  }
  int start = 0, end = 0;
  for (int i = 0; i < n; i++) {
    int one = 0, zero = 0;
    for (int j = i; j < n; j++) {
      if (a[j] == 1) {
        one++;
      } else {
        zero++;
      }
      if ((zero - one) == mx) {
        start = i;
        end = j;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i >= start && i <= end) {
      if (a[i] == 0) {
        ans++;
      }
    } else {
      if (a[i] == 1) {
        ans++;
      }
    }
  }
  cout << ans;
}
