#include #include #include #include #include #include #include using namespace std; typedef long long ll; const int MOD=1e9+7; int main() { int n,a[10000]={},b[10000]={},M,A=0,B=0,d; cin >> n; for(int i=0; i> a[i] >> b[i]; A+=a[i],B+=b[i]; } M=max(A,B); d=abs(A-B); cout << M-d+1 << endl; }