program rezz;
var n:integer;
rez:array[1..10000,1..2] of integer;
ri,ro:text;
x1,x2:integer;
time:longint;
now:integer;
long:longint;
procedure go;
var x:integer;
begin
for x:=1 to n do
begin
if rez[x,1]>=now then
begin
now:=rez[x,2];
time:=time+(rez[x,2]-rez[x,1]);
if long<time then long:=time;
go;
now:=rez[x,1];
time:=time-(rez[x,2]+rez[x,1]);
end;
end;
end;
begin
assign(ri,'rez.in');
assign(ro,'rez.out');
reset(ri);
rewrite(ro);
readln(ri,n);
for x1:=1 to n do
begin
read(ri,rez[x1,1]);
read(ri,rez[x1,2]);
readln(ri);
end;
time:=0;
long:=0;
now:=0;
go;
writeln(ro,long);
close(ri);
close(ro);
end.