#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k = 0, n, x, y, m, cnt0, cnt1, max = 0;
  cin >> n;
  int a[n], z[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      z[k] = i;
      k++;
    }
  }
  if (k == 0) {
    cout << n - 1;
    return 0;
  }
  i = 0;
  while (i < k) {
    j = k - 1;
    while (j >= 0) {
      cnt0 = 0;
      cnt1 = 0;
      for (m = z[i]; m <= z[j]; m++) {
        if (a[m] == 0)
          cnt0++;
        else
          cnt1++;
      }
      if ((cnt0 - cnt1) >= max) {
        max = cnt0 - cnt1;
        x = z[i];
        y = z[j];
      }
      j--;
    }
    i++;
  }
  cnt1 = 0;
  for (i = 0; i < n; i++) {
    if (i >= x && i <= y) {
      if (a[i] == 0) cnt1++;
    } else {
      if (a[i] == 1) cnt1++;
    }
  }
  cout << cnt1;
  return 0;
}
