#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<=2*N; i+=2){ int x = 1; vector w; int allw = 0; rep(j,i){ w.push_back(x); allw += x; if(jallv) break; int sum = 0; rep(j,w.size()){ if(j w[j]) sum += v[j]-w[j]; } REP(j,w.size(),N) sum += v[j]; //cout << w.size() << " " << sum << endl; ret = min(ret, sum); } cout << ret << endl; return 0; }