#include #define rep(i,n) for(int i=0;i pp; const int INF = 1e9; const int MOD = 1000000007; int main() { int n; cin >> n; int a_sum = 0,b_sum = 0;; vector a(n-1),b(n-1); rep(i,n-1){ cin >> a[i] >> b[i]; a_sum += a[i]; b_sum += b[i]; } int m = 0; rep(i,n-1){ m = max(m,a[i]+b[i] - a_sum); } cout << b_sum + 1 - m << endl; return 0; }