implicit none integer::N,i,temp integer::V(1000),first,p,pp,tmp read *, N read *, V(1:N) pp=0 p =V(1) do i=2,N tmp = p p = MAX(p,pp+V(i)) pp = tmp end do print '(i0)',p end