#include int N, A[37], B[37]; int min(int x, int y) { return x < y ? x : y; } int max(int x, int y) { return x > y ? x : y; } int main() { scanf("%d", &N); int sa = 0; int sb = 0; for (int i = 1; i < N; i++) { scanf("%d %d", &A[i], &B[i]); sa += A[i]; sb += B[i]; } int ma = 0; int mb = 0; for (int i = 1; i < 37; i++) { ma = max(ma, B[i] - (sa - A[i])); mb = max(mb, A[i] - (sb - B[i])); } printf("%d\n", min(sb - ma, sa - mb) + 1); return 0; }