1 /*
2 贪心:暴力贪心水水
3 */
4 #include <cstdio>
5 #include <algorithm>
6 #include <cstring>
7 using namespace std;
8
9 const int MAXN = 1e2 + 10;
10 const int INF = 0x3f3f3f3f;
11 int a[MAXN];
12
13 int main(void) //Codeforces Round #191 (Div. 2) A. Flipping Game
14 {
15 int n; scanf ("%d", &n);
16 int sum = 0;
17 for (int i=1; i<=n; ++i) scanf ("%d", &a[i]), sum += a[i];
18
19 int ans = 0;
20 for (int i=1; i<=n; ++i)
21 {
22 for (int j=1; j<=n-i+1; ++j)
23 {
24 int pre = 0; int now = 0;
25 for (int k=j; k<=j+i-1; ++k)
26 {
27 pre += a[k]; now += 1 - a[k];
28 }
29 ans = max (ans, sum - pre + now);
30 }
31 }
32
33 printf ("%d\n", ans);
34
35
36 return 0;
37 }