implicit none integer(8) i,N,j,d integer(8),allocatable :: A(:) integer(8),allocatable :: B(:) integer(8),allocatable :: C(:) read(*,*) N allocate (A(1:N)) allocate (B(1:N)) allocate (C(1:N)) A=0 B=0 C=0 d=0 read(*,*) (A(i),i=1,N) do i=1,N C(i)=maxval(A) A(maxloc(A))=0 end do do i=1,N-1 if (C(i)==C(i+1)) then B(i)=B(i)-1 B(i+1)=B(i+1)-1 end if end do do i=1,N if (B(i)==0) then d=d+1 end if end do write(*,*) d end