why my sollution take WA on test #3

var

p:int64;

i,n,x:integer;

max:int64;

begin

assign(input,'input.txt');

reset(input);

assign(output,'output.txt');

rewrite(output);

readln(n);

readln(p);

max:=p;

for i:=1 to n-1 do

begin

readln(x);

if x>=p+x then p:=x else p:=p+x;

if p>max then max:=p;

end;

if max<0 then writeln(0) else writeln(max);

end.

*Edited by author 18.11.2009 00:20*

*Edited by author 18.11.2009 00:21*

*Edited by author 18.11.2009 00:23*