program abc159d
  use iso_fortran_env
  implicit none
  integer(int64) :: n, i
  integer(int64),dimension(:),allocatable :: a, freq, cmb, ans
  read *, n
  allocate(a(n), freq(n))
  read *, a
  freq = 0
  do i = 1,n
     freq(a(i)) = freq(a(i)) + 1
  end do
  cmb = freq * (freq - 1) / 2
  ans = sum(cmb) - (freq(a) - 1)
  print *, ans
end program abc159d
