#include using namespace std; int main() { int n; cin >> n; int asum = 0; int bsum = 0; int maxi = 0; for (int i = 0; i < n-1; i++) { int c, d; cin >> c >> d; asum += c; bsum += d; maxi = max(maxi, c+d); } int ans = 0; for (int a = 0; a <= bsum; a++) { if (asum+a >= maxi) ans++; } cout << ans << endl; return 0; }