#include using namespace std; #define int long long using ll=long long; using vi=vector; using vl=vector; using pii=pair; using pll=pair; #define ITR(v,c) for(auto v=begin(c);v!=end(c);++v) #define FORE(x,c) for(auto &x:c) #define FOR(v,a,n) for(int v=a;v<(int)(n);++v) #define REP(v,n) FOR(v,0,n) #define RREP(v,n) for(int v=((int)(n)-1);v>=0;--v) #define ALL(c) begin(c),end(c) #define RALL(c) rbegin(c),rend(c) #define SZ(c) ((int)c.size()) #define dump(...) const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0}; const int INF=1e9*2; const long long INFLL=1e18*2; template ostream& operator << (ostream &os, const vector &v) { ITR(i,v) os<<*i<<(i==end(v)-1?"":"\n"); return os; } template istream& operator >> (istream &is, vector &v) { ITR(i,v) is>>*i; return is; } //------------------------------------------------------------------------------ signed main() { int n; cin>>n; vi b(n); cin>>b; ll left=1,m,right=1e18; while(right-left>0) { m=(left+right)/2; vi a(n+1,0); a[0]=m; a[1]=b[0]-m; if(a[1]<1) { right=m; continue; } FOR(i,2,n+1) { if(i%2==0) { a[i]=a[i-1]-b[i-1]; if(a[i]<1) { right=m; goto next; } if(a[i]>1e18) { left=m; goto next; } } else { a[i]=b[i-1]-a[i-1]; if(a[i]<1) { left=m; goto next; } if(a[i]>1e18) { right=m; goto next; } } } { cout<