// yuki 904 サメトロ // 2019.10.11 bal4u #include #include #include #include #define gc() getchar() #define pc(c) putchar(c) int in() { // 整数の入力 int n = 0, c = gc(); while (isspace(c)) c = gc(); if (c == '-') { c = gc(); do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return -n; } do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return n; } int SA, SB; int main() { int i, A, B, N; N = in(); SA = SB = 0; for (i = 2; i <= N; i++) { A = in(), B = in(); SA += A, SB += B; } if (SA > SB) SA = SB; printf("%d\n", SA+1); return 0; }