#include <bits/stdc++.h>

using namespace std;
#define int long long

const int N = 1100000;
const int INF = (int)(4e18);

int n, a[N], b[N], p[N], l[N], r[N], v[N];
vector<int> pos;

int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
        l[i] = 0;
        r[i] = i - 1;
    }
    int sum = 0, ans = -INF;
    for (int i = 1; i <= n; i++) {
        sum += a[i];
        if (sum > ans) ans = sum;
    }
    cout << ans;
    return 0;
}