import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int n;
    scan(n);

    auto x = new long[](n + 1);
    auto s = new int[](n + 1);

    foreach (i ; 1 .. n + 1) {
        scan(x[i], s[i]);
    }

    auto p = new long[](n + 1);
    p[1] = s[1];
    foreach (i ; 2 .. n + 1) {
        p[i] = p[i-1] + s[i] - (x[i] - x[i-1]);
    }
    auto pm = new long[](n + 1);
    pm[n] = p[n];
    foreach_reverse (i ; 1 .. n) {
        pm[i] = max(p[i], pm[i+1]);
    }

    long ans = pm[1];
    long d;

    foreach (i ; 2 .. n+1) {
        d += (x[i]-x[i-1]) - s[i-1];
        ans = max(ans, pm[i] + d);
    }

    writeln(ans);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}