#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  int ans = 0;
  for (int l = 0; l < N; ++l)
    for (int r = l; r < N; ++r) {
      int cnt = 0;
      for (int i = 0; i < l; ++i) cnt += A[i];
      for (int i = l; i < r + 1; ++i) cnt += (A[i] ^ 1);
      for (int i = r + 1; i < N; ++i) cnt += A[i];
      ans = max(ans, cnt);
    }
  cout << ans << '\n';
  return 0;
}
