#include #include int n, inSum, outSum; int in[40], out[40]; void swap(int *x, int *y) { int tmp = *x; *x = *y; *y = tmp; } int main(void) { scanf("%d", &n); for (int i = 0; i < n-1; ++i) { scanf("%d %d", &in[i], &out[i]); inSum += in[i]; outSum += out[i]; } if (inSum > outSum) swap(&inSum, &outSum); int mn = 0, mx = inSum; printf("%d\n", mx - mn + 1); }