program DoubleBooking integer,allocatable,dimension(:)::R integer::P1,P2,N,k,sum,X sum=0 write(*,*)'Please enter P1,P2' read *,P1,P2 write(*,*)'Please enter N' read *,N allocate(R(N)) write(*,*)'Please enter R(N)' read *,R(:) do X=1,999 if(count(X==R(:))<2) cycle sum=sum+count(X==R(:))-1 end do write(*,*)sum*(P1+P2) end program DoubleBooking