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

alias Pair = Tuple!(long, "p", int, "r");

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 mh = new BinaryHeap!(Array!Pair)();
    long d;
    long p = s[1];

    mh.insert(Pair(s[1], 1));

    foreach (i ; 2 .. n + 1) {
        p += s[i] - (x[i] - x[i-1]);
        mh.insert(Pair(p, i));
    }

    long ans = s[1];

    foreach (i ; 1 .. n) {
        d += x[i + 1] - x[i] - s[i];

        while (mh.front.r <= i) {
            mh.popFront();
        }

        debug {
            writeln(d);
            writeln(mh.front);
        }

        ans = max(ans, mh.front.p + 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);
        }
    }
}