   program abc159d
      implicit none
      integer::N,k,sum
      integer,allocatable,dimension(:)::A,B,C

!配列Aは元データ(N)、Bはk番目を除いたもの(N-1)
!配列CはB内の数がそれぞれ何個ずつあるかのカウント配列
!配列XはBのデータがカウントされた場合1→0になるチェック配列(N-1)

         read *, N
         allocate(A(N))
         read *, A
         allocate(B(N-1))
         allocate(C(N-1))

         do k=1,N
            call except_k(A,B,k,N)
            call count(B,C,N)
            sum=sumcount(C,N)
            print *,sum
         end do
         stop

      contains
      subroutine except_k(A,B,k,N)
         implicit none
         integer,intent(in)::k,N
         integer,dimension(*),intent(in)::A
         integer,dimension(*),intent(out)::B
         integer::i
            do i=k,N-1
               B(i)=A(i+1)
            end do
            if (k-1>=1) then
               do i=1,k-1
                  B(i)=A(i)
               end do
            else
               continue
            end if
            return
      end subroutine except_k

      subroutine count(B,C,N)
         implicit none
         integer,intent(in)::N
         integer,dimension(*),intent(in)::B
         integer,dimension(*),intent(out)::C
         integer,allocatable,dimension(:)::X
         integer::i,j,l
            allocate(X(N-1))
            X=1
            j=1
            C(1:N-1)=0
            do i=1,N-1
               if (X(i)==1) then
                  C(j)=0
                  X(i)=0
                  do l=i,N-1
                     if(B(i)==B(l)) then
                        C(j)=C(j)+1
                        X(l)=0
                     end if
                  end do
                  j=j+1
               end if
            end do
            return
      end subroutine count

      function sumcount(C,N)
         implicit none
         integer,intent(in)::N
         integer,dimension(*),intent(in)::C
         integer::sumcount,i
            sumcount=0
            do i=1,N-1
               sumcount=sumcount+C(i)*(C(i)-1)/2
            end do
            return
      end function sumcount

   end program abc159d