#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#define ll long long
#define X first
#define Y second
#define endl '\n'
using namespace std;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
const int MAXN=1010000;
int a[MAXN],b[MAXN];
int n;
int p[MAXN];
void read()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
    }
    for(int i=1;i<=n;i++)cin>>p[i];
}
signed main()
{
    speed();
    read();
    int ans=0;
    int bans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=a[i];
        bans=max(ans,bans);
    }
    cout<<bans<<endl;
    return 0;
}