#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[100];
  int n;
  cin >> n;
  int ans = 0;
  int ones = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    arr[i] = a;
    ones += a;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      int temp = 0;
      for (int k = 0; k < j - i + 1; k++) {
        temp += arr[k + i];
      }
      temp = ones - 2 * temp + j - i + 1;
      if (temp > ans) {
        ans = temp;
      }
    }
  }
  cout << ans;
}
