var
a,t:array[-200005..200005] of longint;
f,temp:array[-200005..200005] of int64;
n:longint;
ans:int64;
function max(xx,yy:int64):int64;
begin
if xx<=yy then exit(yy);
exit(xx);
end;
procedure init;
var i:longint;
begin
readln(n);
for i:=1 to n do
readln(a[i],t[i]);
end;
function find(xx:longint):longint;
var i,j:longint;
begin
for i:=xx+1 to n do
if a[i]<a[xx] then exit(i);
exit(0);
end;
procedure main;
var i,j:longint;
begin
fillchar(f,sizeof(f),0);
fillchar(temp,sizeof(temp),0);
f[n]:=int64(a[n]+t[n]);
for i:=n-1 downto 1 do
begin
if a[i]>a[i+1] then
f[i]:=f[i+1]+int64(t[i])+int64(a[i]+1-a[i+1])
else
begin
j:=find(i);
if j=0 then
f[i]:=int64(n-i+a[i])+int64(t[i])
else
f[i]:=f[j]+int64(j-i+a[i]-a[j])+int64(t[i]);
end;
end;
ans:=0;
for i:=1 to n do
ans:=max(ans,f[i]);
writeln(ans);
end;
begin
assign(input,'boarding.in');reset(input);
assign(output,'boarding.out');rewrite(output);
init;main;
close(input);close(output);
end.