#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 5;
int a[maxn];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    int ans = 0;
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
    for (int i = 0; i < n; ++i)
      for (int j = i; j < n; ++j) {
        int sum = 0;
        for (int k = 0; k < i; ++k) sum += a[k];
        for (int k = i; k <= j; ++k) sum += 1 - a[k];
        for (int k = j + 1; k < n; ++k) sum += a[k];
        ans = max(ans, sum);
      }
    cout << ans << endl;
  }
  return 0;
}
