#include #include int n, inSum, outSum; int in[40], out[40]; 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) printf("%d\n", abs(inSum - outSum)); else printf("%d\n", inSum + 1); }