integer::N,M,i integer,allocatable::card(:) integer,allocatable::A(:) read *, N, M allocate(card(N)) allocate(A(M)) read *, A card=(/(i,i=1,N)/) do i=1, M card = [card(A(i)),pack(card,card.ne.card(A(i)))] end do print '(i0)', card(1) end program