#include #include #include #include #include #include #include #include #include #include #include #include #define vll vector #define vvvl vector #define vvl vector> #define VV(a, b, c, d) vector>(a, vector(b, c)) #define VVV(a, b, c, d) vector(a, vvl(b, vll (c, d))); #define re(c, b) for(ll c=0;c> n; ll sa = 0, sb = 0; ll maxa = 0, maxb = 0; re(i, n-1){ ll a, b;std::cin >> a >> b; sa += a, sb += b; maxa = max(maxa, a); maxb = max(maxb, b); } ll ans = 0; ll D = sa - sb; for(ll i=max(0LL, -D);i<=400000;i++){ ll x = i, y = i + D; if(x>sb||y>sa) continue; ans++; } std::cout << ans << '\n'; }