#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; int main(){ int N, tmp; vector v; cin >> N; int allv = 0; rep(i,N){ cin >> tmp; v.push_back(tmp); allv += tmp; } int ret = 100000000; for(int i=1; i<=N; i+=2){ int x = 1; vector w; int allw = 0; rep(j,i){ w.push_back(x); allw += x; if(jallv) break; rep(st,N-w.size()+1){ int sum = 0; rep(j,st) sum += v[j]; rep(j,w.size()){ if(v[st+j] > w[j]) sum += v[st+j]-w[j]; } REP(j,st+w.size(),N) sum += v[j]; ret = min(ret, sum); } } cout << ret << endl; return 0; }