#include using namespace std; using lli = long long int; template ostream &operator<<(ostream &o,const vector&v) {o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<ostream &operator<<(ostream &o,const pair&p) {o<<"("<> n; lli si = 0, so = 0; for(lli i = 0; i < n-1; i++){ lli tmp; cin >> tmp; si+=tmp; cin >> tmp; so+=tmp; } lli a, b; lli c = 0; if(si - so < 0) b = 0; else b = si - so; a = b + so - si; while(a <= so && b <= si){ c++; a++; b++; } cout << c << endl; return 0; }