Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale from one of m genres.

In the bookshop, Jack decides to buy two books of different genres.

Based on the genre of books on sale in the shop, find the number of options available to Jack for choosing two books of different genres for Emily. Options are considered different if they differ in at least one book.

The books are given by indices of their genres. The genres are numbered from 1 to m.


-----Input-----

The first line contains two positive integers n and m (2 ≤ n ≤ 2·10^5, 2 ≤ m ≤ 10) — the number of books in the bookstore and the number of genres.

The second line contains a sequence a_1, a_2, ..., a_{n}, where a_{i} (1 ≤ a_{i} ≤ m) equals the genre of the i-th book.

It is guaranteed that for each genre there is at least one book of that genre.


-----Output-----

Print the only integer — the number of ways in which Jack can choose books.

It is guaranteed that the answer doesn't exceed the value 2·10^9.


-----Examples-----
Input
4 3
2 1 3 1

Output
5

Input
7 4
4 2 3 1 2 4 3

Output
18



-----Note-----

The answer to the first test sample equals 5 as Sasha can choose:  the first and second books,  the first and third books,  the first and fourth books,  the second and third books,  the third and fourth books.

Difficulty: interview

Starter code:

Solutions:
a, b = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
stot = 0
ssq = 0
for i in range(1, b+1):
    stot += l.count(i)
    ssq += (l.count(i)**2)

print(int((stot**2 - ssq)/2))

n, m = list(map(int, input().split()))
v = list(map(int, input().split()))

cnt = [0 for i in range(0, m+1)]

for x in v:
    cnt[x] += 1

sol = n * (n-1) // 2

for x in cnt:

    sol -= x * (x-1) // 2

print(sol)



#!/usr/bin/env python3

from collections import Counter

def solve():
    N, M = list(map(int, input().split()))
    gen = list(map(int, input().split()))

    cnt = Counter(gen)

    total = 0
    for gen1, cnt1 in list(cnt.items()):
        for gen2, cnt2 in list(cnt.items()):
            if gen1 == gen2:
                continue
            total += cnt1 * cnt2
    print(total//2)

def __starting_point():
    solve()

__starting_point()

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
p = [0] * m
for i in range(n):
    p[a[i] - 1] += 1
ans = 0
for i in range(m):
    ans += p[i] * (n - p[i])
print(ans // 2)


n, m = list(map(int, input().split()))
L = list(map(int, input().split()))
T = [0 for _ in range(m)]
for k in range(n):
    T[L[k]-1]+=1
r = 0
for i in range(m-1):
    for j in range(i+1,m):
        r+= T[i]*T[j]
print(r)


read = lambda: list(map(int, input().split()))
n, m = read()
a = list(read())
p = [0] * 20
for i in a:
    p[i] += 1
cnt = n * (n - 1) // 2
for i in p:
    cnt -= i * (i - 1) // 2
print(cnt)


from collections import Counter
n, m = list(map(int, input().split()))
c = Counter(list(map(int, input().split())))
a = list(c.keys())
print(sum(c[a[i]] * c[a[j]] for i in range(len(a) - 1) for j in range(i + 1, len(a))))



n, m = [int(x) for x in input().split()]
books = [int(x) for x in input().split()]
D = {i:0 for i in range(1,m+1)}
for i in range(n):
    D[books[i]] += 1

res = 0
for k in D:
    res += D[k] * (n - D[k])

print(res // 2)


from bisect import *
def inpList():
    return list(map(int,input().split()))
def inp():
    return int(input())
n,m=inpList()
a=inpList()
x={}
for i in range(1,m+1):
    x[i]=0
for i in a:
    x[i]+=1
p=sum(x[i] for i in x)
t=sum(x[i]*x[i] for i in x)
print((p*p-t)//2)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time

(n, m) = (int(i) for i in input().split())
a   = [int(i) for i in input().split()]

start = time.time()

d   = {}
ans = 0

for i in range(m):
    d[i] = 0

for i in a:
    d[i-1] += 1

k = n
for i in range(m-1):
    k   -= d[i]
    ans += d[i]*k

print(ans)
finish = time.time()
#print(finish - start)


n, m = map(int, input().strip().split())
g = [0]*m
for a in map(int, input().strip().split()):
	g[a-1] += 1

total = 0
for i in range(m):
	for j in range(i+1, m):
		total += g[i]*g[j]

print(total)

n, m = [int(i) for i in input().split()]
lst = [0 for i in range(m)]
inp = [int(i) for i in input().split()]

for i in inp:
    lst[i - 1] += 1
lst = [ i * (i - 1) // 2 for i in lst if i > 1 ]
print((n * (n - 1) // 2) - sum(lst))


n,m = list(map(int, input().split()))
l = list(map(int, input().split()))
num = [0]*int(2*1e5+5)
for i in l:
    num[i] += 1
ans = n*(n-1)//2
for i in num:
    ans -= i*(i-1)//2
print(ans)


__author__ = 'Utena'
n,m=map(int,input().split())
s=list(map(int,input().split()))
v=[0]*m
for i in s:
    v[i-1]+=1
t=0
for j in range(m):
    t1=v[j]
    t2=0
    for r in range(j+1,m):
        t2+=t1*v[r]
    t+=t2
print(t)

n,m=input().split()
n,m=int(n),int(m)
l=[0]*m
s=input().split()
for i in range(n):
    l[int(s[i])-1]+=1
r=0
for i in range(m):
   r+=l[i]
p,q=0,0
for i in range(m):
    p+=l[i]
    q+=l[i]*(r-p)
print(q)

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
count = 0
for i in range(m):
    for j in range(i+1,m):
        count += a.count(i+1)*a.count(j+1)
print(count)

n,m=list(map(int,input().split()))
s1=list(map(int,input().split()))
a=[0]*m
for i in range (n):
    a[s1[i]-1]+=1
kol=0
for i in range (m-1):
    for j in range (i+1,m):
        kol=kol+a[i]*a[j]
print(kol)


n,m=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
b=list(set(a))
num=0
for i in b:
    for t in b:
        if i!=t:
           num+=a.count(i)*a.count(t)
print(num//2)



n,m=list(map(int,input().split()))
mas=list(map(int,input().split()))
masc=[0]*(m+1)
for i in range(1,m+1):
    masc[i]=mas.count(i)
i=1
var=0
while masc[i]>0:
    var+=masc[i]*sum(masc[i+1:])
    i+=1
    if i >= len(masc):
        break
print(var)


#bismillah
n,m=list(map(int,input().split()))
a=list(map(int,input().split(' ')))
o=0;c=0;t=[];sm=n
for i in range(m+1):
       t.append(0)
for i in range(n):
       t[a[i]]+=1
for i in range(1,m+1):
    sm-=t[i]
    o+=t[i]*sm
print(o)
    


a=input().split()
n=int(a[0])
m=int(a[1])

kn=[]
k=input().split()
for i in range(n):
	kn+=[int(k[i])]

c=0
for i in range(m):
	c+=kn.count(i+1)*(n-kn.count(i+1))
print(int(c/2))

#!/usr/bin/env python3

from collections import Counter
from itertools import combinations

# n: number of books
# m: number of genres
n, m = map(int, input().split())
genres = Counter(map(int, input().split()))

count = 0
for a, b in combinations(range(1, m+1), 2):
    count += genres[a] * genres[b]
print(count)

n, m = map(int, input().split())
a = list(map(int, input().split()))

v = [0] * (m + 1)

for i in a:
    v[i] += 1

an = n * (n - 1) // 2

for i in v:
    an -= i * (i - 1) // 2

print(an)

n, m = map(int, input().split())
genres = list(map(int, input().split()))
q = [0] * m
for i in range(n):
    q[genres[i] - 1] += 1
print(sum(q[i] * q[j] for i in range(m) for j in range(i + 1, m)))

# -*- coding: utf-8 -*-
"""
Created on Sat Dec 19 15:38:18 2015

@author: kebl4230
"""
aa = [int(num) for num in input().split()]
books = [int(num) for num in input().split()]
result = 0
for genre in range(1, aa[1]+1):
    n = books.count(genre)
    aa[0] -= n
    result += n * aa[0]
print(result)