program main implicit none integer::N,i,temp integer::V(1001),total(0:1001) read *, N read *, V(1:N) total(0)=0 total(1)=V(1) do i=2,N-1,2 temp = MAX(total(i-1),total(i-2)+V(i)) total(i) = temp total(i+1) = MAX(temp, total(i-1)+V(i+1)) end do print '(i0)',total(N) end program