#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e18, MOD = 998244353;
mt19937 rnd(time(0));

void solve();

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> pa(n + 1);
    vector<int> pb(n + 1);
    for (int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        pa[i + 1] = pa[i] + a;
        pb[i + 1] = pb[i] + b;
    }
    vector<int> p(n + 1, -1);
    for (int i = 1; i < n + 1; i++){cin >> p[i];}
    int ans = 0;
    for (auto x : pa){
        ans = max(x, ans);
    }
    cout << ans;
}





