program coprime
  implicit none
  integer :: n, m, c, p, i
  integer, allocatable :: a(:), b(:)
  character(8), parameter :: x = 'pairwise', y = 'setwise ', z = 'not     '
  read(*,*) n
  allocate(a(n))
  read(*,*) a
  m = maxval(a(1:n))
  allocate(b(m))
  b = 0
  do i = 1, n
    c = a(i)
    p = 2
    do while (p * p <= c)
      if (mod(c, p) == 0) then
        b(p) = b(p) + 1
        do while (mod(c, p) == 0)
          c = c / p
        end do
      end if
      p = p + 1
    end do
  end do
  write(*,'(a)') trim(merge(x, merge(y, z, all(b < n)), all(b < 2))) // ' coprime'
end program coprime