program papers_please
    integer(4):: n, i
    integer(4),allocatable:: a(:)
    logical:: is_denied = .false.

    read*, n
    allocate(a(n))
    read*, a(:)
    
    do i=1,n
        if (mod(a(i),2) /= 0) cycle
        if (mod(a(i),3)/=0 .and. mod(a(i),5)/=0) is_denied = .true.
    end do

    if (is_denied) then
        print*, "DENIED"
    else
        print*, "APPROVED"
    end if
end program papers_please