Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N, X, Y = map(int, input().split())
dist = [0]*N
for i in range(N):
    for k in range(i,N):
        if i == X - 1 and k == Y - 1:
            dist[1] += 1
            continue
        if X - 1 <= k <= Y - 1 and i <= X - 1:
            tmp = min(k-i,(X-1)-i+1+(Y-1-k))
            dist[tmp] += 1
            continue
        if X - 1 < i < Y - 1 and k >= Y - 1:
            tmp = min(k-i,i-(X-1)+1+k-(Y-1))
            dist[tmp] += 1
            continue
        if X - 1 <= k <= Y - 1 and X - 1 <= i <= Y - 1:
            tmp = min(k-i,i-(X-1)+1+(Y-1-k))
            dist[tmp] += 1
            continue
        if i <= X - 1 and k >= Y - 1:
            dist[k-i-(Y-X-1)] += 1
            continue
        dist[k-i] += 1
for i in range(1,N):
    print(dist[i])

### FIXED CODE ###

N, X, Y = map(int, input().split())
dist = [0]*N
for i in range(N):
    for k in range(i+1,N):
        if i == X - 1 and k == Y - 1:
            dist[1] += 1
            continue
        if X - 1 <= k <= Y - 1 and i <= X - 1:
            tmp = min(k-i,(X-1)-i+1+(Y-1-k))
            dist[tmp] += 1
            continue
        if X - 1 < i < Y - 1 and k >= Y - 1:
            tmp = min(k-i,i-(X-1)+1+k-(Y-1))
            dist[tmp] += 1
            continue
        if X - 1 <= k <= Y - 1 and X - 1 <= i <= Y - 1:
            tmp = min(k-i,i-(X-1)+1+(Y-1-k))
            dist[tmp] += 1
            continue
        if i <= X - 1 and k >= Y - 1:
            dist[k-i-(Y-X-1)] += 1
            continue
        dist[k-i] += 1
for i in range(1,N):
    print(dist[i])
### BUGGY CODE ###

n = int(input())
a = list(map(lambda x:int(x)-1,input().split()))
count = [0]*n
for i in a:
    count[i]+=1
for i in a:
    ans = 0
    for j in range(n):
        k = count[j]
        if j == i:
            k -= 1
        ans += k*(k-1)//2
    print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(lambda x:int(x)-1,input().split()))
count = [0]*n
for i in a:
    count[i]+=1
sum=0
for i in count:
    sum += i*(i-1)//2

for i in a:
    ans = sum-count[i]+1
    print(ans)
### BUGGY CODE ###

import collections

n = int(input())
List = [input() for i in range(n)]
res = []

c = collections.Counter(List)

leng = len(c)

res.append(c.most_common()[0][0])
for i in range(1, leng):
    if c.most_common()[i][1] >= c.most_common()[i-1][1]:
        res.append(c.most_common()[i][0])
    else:
        break

res = sorted(res)
for j in range(len(res)):
    print(res[j])

### FIXED CODE ###

import collections

n = int(input())
List = [input() for i in range(n)]
res = []

c = collections.Counter(List)
m = 0
for v in c.values():
  m = max(m, v)
  
for k, v in c.items():
  if v == m:
    res.append(k)
    
res.sort()
for i in range(len(res)):
  print(res[i])
### BUGGY CODE ###

def solve(i, m):
    if m == 0:
        return True
    if i == n or m < 0:
        return False

    res = solve(i + 1, m) or solve(i + 1, m - A[i])
    return res


n = int(raw_input())
A = map(int, raw_input().split())

q = int(raw_input())
M = map(int, raw_input().split())

for i in M:
    print "yes" if solve(0, i) else "no"

### FIXED CODE ###

def solve(i, m):
    if m == 0: return True

    if i < n and min(A[i:]) <= m <= sum(A[i:]):
        r1 = solve(i + 1, m-A[i])
        if r1: return r1
        r2 = solve(i + 1, m)
        if r2: return r2


n = int(raw_input())
A = map(int, raw_input().split())

q = int(raw_input())
M = map(int, raw_input().split())

for i in M:
    print "yes" if solve(0, i) else "no"
### BUGGY CODE ###

N, K = map(int, input().split())
A = map(int, input().split())
A = [a - 1 for a  in A]

visit = [0] * N
turn = [-1] * N

visit[0] = 1
turn[0] = 0

def judge(v):
    for i, _v in enumerate(v):
        if _v > 1:
            return (True, i)
    return (False, 0)

cursor = 0
turn_count = 0
while True:
    cursor = A[cursor]
    turn_count += 1

    if turn_count == K:
        print(cursor+1)
        exit()

    visit[cursor] += 1

    flag, i = judge(visit)
    if flag:
        loop_length = turn_count - turn[i]
        break

    turn[cursor] = turn_count

K -= turn[i]
K %= loop_length

cursor = i
for _ in range(K):
    cursor = A[cursor]

print(cursor + 1)


### FIXED CODE ###

N, K = map(int, input().split())
A = map(int, input().split())
A = [a - 1 for a  in A]

visit = [0] * N
turn = [-1] * N

visit[0] = 1
turn[0] = 0

cursor = 0
turn_count = 0
while True:
    cursor = A[cursor]
    turn_count += 1

    if turn_count == K:
        print(cursor+1)
        exit()

    visit[cursor] += 1

    if visit[cursor] > 1:
        loop_length = turn_count - turn[cursor]
        break

    turn[cursor] = turn_count

K -= turn[cursor]
K %= loop_length

for _ in range(K):
    cursor = A[cursor]

print(cursor + 1)
### BUGGY CODE ###

class SegmentTree: #1-indexed
    def __init__(self,list,f=lambda x,y:x+y,inf=0):
        self.height=(len(list)-1).bit_length()+1 #木の高さ
        self.id=inf #単位元
        self.tree=[self.id]*(2**self.height) #木を単位元で初期化
        self.f=f
        for i in range(len(list)):
            self.tree[2**(self.height-1)+i]=list[i]
        for i in range(2**(self.height-1)-1,0,-1):
            self.tree[i]=self.f(self.tree[2*i],self.tree[2*i+1])
        
    def update(self,i,x): #i番目の要素をxに変更
        i+=2**(self.height-1)
        self.tree[i]+=x
        while i>1:
            i//=2
            self.tree[i]=self.f(self.tree[2*i],self.tree[2*i+1])
    
    def query(self,l,r):
        l+=2**(self.height-1)
        r+=2**(self.height-1)
        lf,rf=self.id,self.id
        while l<r:
            if l&1:
                lf=self.f(lf,self.tree[l])
                l+=1
            if r&1:
                r-=1
                rf=self.f(self.tree[r],rf)
            l//=2
            r//=2
        return self.f(lf,rf)

n,q=map(int,input().split())
x=list(map(int,input().split()))
S=SegmentTree(x)
for i in range(q):
    a,b,c=map(int,input().split())
    if a==0:
        S.update(b,c)
    else:
        print(S.query(b,c))

### FIXED CODE ###

class SegmentTree: #1-indexed
    def __init__(self,list,f=lambda x,y:x+y,inf=0):
        self.height=(len(list)-1).bit_length()+1 #木の高さ
        self.id=inf #単位元
        self.tree=[self.id]*(2**self.height) #木を単位元で初期化
        self.f=f
        for i in range(len(list)):
            self.tree[2**(self.height-1)+i]=list[i]
        for i in range(2**(self.height-1)-1,0,-1):
            self.tree[i]=self.f(self.tree[2*i],self.tree[2*i+1])
        
    def update(self,i,x): #i番目の要素をxに変更
        i+=2**(self.height-1)
        self.tree[i]+=x
        while i>1:
            i//=2
            self.tree[i]=self.f(self.tree[2*i],self.tree[2*i+1])
    
    def query(self,l,r):
        l+=2**(self.height-1)
        r+=2**(self.height-1)
        lf,rf=self.id,self.id
        while l<r:
            if l&1:
                lf=self.f(lf,self.tree[l])
                l+=1
            if r&1:
                r-=1
                rf=self.f(self.tree[r],rf)
            l//=2
            r//=2
        return self.f(lf,rf)

n,q=map(int,input().split())
x=list(map(int,input().split()))
S=SegmentTree(x)
for i in range(q):
    a,b,c=map(int,input().split())
    if a==0:
        S.update(b,c)
    else:
        print(S.query(b,c))
### BUGGY CODE ###

S = input()
Q = int(input())


for _ in range(Q):
    query = input()
    if query[0] == '1':
        S = S[::-1]
    else:
        _, f, c = query.split()
        if f == '1':
            S = c + S
        else:
            S = S + c

print(S)

### FIXED CODE ###

S = input()
Q = int(input())

lS = ''
for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        lS, S = S, lS
    else:
        if query[1] == '1':
            lS += query[2]
        else:
            S += query[2]

print(lS[::-1] + S)
### BUGGY CODE ###

#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


#A
"""
a,b = LS()
if a == b:
    print("H")
else:
    print("D")
"""

#B
"""
w,a,b = LI()
print(max(max(a,b)-min(a,b)-w,0))
"""

#C
"""

x = I()
a = 0
i = 1
while a < x:
    a += i
    i += 1
print(i-1)
"""

#D
n,k = LI()
a = LI()
a.sort()
a = a[:bisect.bisect_left(a,k)]
n = len(a)
l = -1
r = n
while r-l > 1:
    m = (l+r)//2
    k_ = k-a[m]
    dp = defaultdict(int)
    dp[0] = 1
    for i in range(n):
        if i == m:continue
        ai = a[i]
        d = list(dp.keys())
        for j in d:
            dp[j+ai] = 1
            if k_ <= j+ai < k:
                r = m
                break
        else:
            continue
        break
    else:
        l = m
print(r)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


#A
"""
a,b = LS()
if a == b:
    print("H")
else:
    print("D")
"""

#B
"""
w,a,b = LI()
print(max(max(a,b)-min(a,b)-w,0))
"""

#C
"""

x = I()
a = 0
i = 1
while a < x:
    a += i
    i += 1
print(i-1)
"""

#D
n,k = LI()
a = LI()
a.sort()
a = a[:bisect.bisect_left(a,k)]
n = len(a)
a = a[::-1]
l = -1
r = n
while r-l > 1:
    m = (l+r)//2
    k_ = k-a[m]
    dp = [0]*k
    dp[0] = 1
    ma = 0
    for i in range(n):
        if i == m:continue
        ai = a[i]
        for j in range(min(ma+1,k-ai))[::-1]:
            j_ = j+ai
            if dp[j]:
                if k_ <= j_:
                    l = m
                    break
                dp[j_] = 1
                if j_ > ma:
                    ma = j_
        else:
            continue
        break
    else:
        r = m
print(n-r)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T
### BUGGY CODE ###

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

for i in a:
    if a.count(i)>1:
        print('NO')
        exit()
        
print('YES')      

### FIXED CODE ###

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

if len(a)==len(b):
    print('YES')
else:
    print('NO')
### BUGGY CODE ###

N=int(input())
I=[int(input()) for i in range(N)]
r=max(I)
for j in range(N):
	X=int(I[j])
	if X!=r:
		print(r)
	else:
		I.remove(I[j])
		print(max(I))
		I.insert(j,X)

### FIXED CODE ###

N=int(input())
I=[int(input()) for i in range(N)]
r=max(I)
if I.count(r)>=2:
	for j in range(N):
		print(r)
else:
	for k in range(N):
		X=int(I[k])
		if X!=r:
			print(r)
		else:
			I.remove(I[k])
			print(max(I))
			I.insert(k,X)
### BUGGY CODE ###

#C
#入力
K=int(input())+1


#デバッグ用
def pront(*n):
    if debug==1:
        print(n)
        
debug=1#0:本番,1:デバッグ

#処理
import math as m

Z=[ [ [-1 for i in range(K)] for j in range(K)] for l in range(K)]
def C_1(i,j,k):
    xx=[i,j,k]
    xx.sort()
    if Z[xx[0]][xx[1]][xx[2]]!=-1:
        return Z[xx[0]][xx[1]][xx[2]]
    else:
        Z[xx[0]][xx[1]][xx[2]]=m.gcd(m.gcd(xx[0],xx[1]),xx[2])
        return Z[xx[0]][xx[1]][xx[2]]


x=0
for i in range(1,K):
    for j in range(1,K):
        if m.gcd(i,j)==1:
            x+=K-1
        else:
            for k in range(1,K):
                x+=C_1(i,j,k)
print(x)

### FIXED CODE ###

#C
#入力
K=int(input())


#デバッグ用
def pront(*n):
    if debug==1:
        print(n)
        
debug=1#0:本番,1:デバッグ

#処理
import math as m
Z=[ [-1 for i in range(K+1)] for j in range(K+1)]
def C_1(i,j):
    if Z[i][j]!=-1:
        return Z[i][j]
    else:
        x=m.gcd(i,j)
        Z[i][j]=x
        Z[j][i]=x
        return Z[i][j]

x=0
for i in range(1,K+1):
    for j in range(1,K+1):
        y=C_1(i,j)
        if y==1:
            x+=K
        else:
            for k in range(1,K+1):
                x+=C_1(y,k)
print(x)
### BUGGY CODE ###

def main():
    N=int(input())
    A=list(map(int, input().split()))
    B=list(map(int, input().split()))

    count = 0
    prev_count = -1
    while count!=prev_count:
        prev_count = count
        for i in range(N):
            d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
            c = (B[i]-A[i]) // d
            B[i] -= d * c
            count += c

    if A == B:
        print(count)
    else:
        print(-1)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N=int(input())
    A=list(map(int, input().split()))
    B=list(map(int, input().split()))

    count = 0
    prev_count = -1
    while count!=prev_count:
        prev_count = count
        for i in range(N):
            d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
            c = (B[i]-A[i]) // d
            B[i] -= d * c
            count += c

    if A == B:
        print(count)
    else:
        print(-1)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

def main():

	#s = tuple(input())
	s = input()
	length = len(s)

	dp = [[0]*13 for _ in range(length)]
	MOD = 10**9+7
	if s[-1] == '?':
		for i in range(10):
			dp[0][i] = 1
	else:
		dp[0][int(s[-1])] = 1

	for i in range(1,length):
		num = (10**i) % 13
		if s[-i-1] != '?':
			num *= int(s[-i-1])
			for j in range(13):
				dp[i][(num+j)%13] = dp[i-1][j] % MOD
		else:
			for j in range(10):
				for k in range(13):
					dp[i][(num*j+k)%13] += dp[i-1][k] % MOD

	print(dp[-1][5] % MOD)

if __name__ == '__main__':
	main()


### FIXED CODE ###

INF = 10 ** 9 + 7

S = input()
# dp[i][j]はうしろからi桁を13で割った余りがjであるものの個数
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= INF
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= INF
    mul = mul * 10 % 13  # 計算量削減のためここで13で割っている

print(dp[len(S)][5])
### BUGGY CODE ###

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

count = n

right_shakutori = [0] 
left_shakutori = [0] 

for i in range(len(a)):
    right_shakutori.append(right_shakutori[i] + a[i])
    left_shakutori.append(left_shakutori[i] ^ a[i])

for l in range(0, n):
    for r in range(l + 1,n):

        right = right_shakutori[r+1] - right_shakutori[l]

        left = left_shakutori[r+1] ^ left_shakutori[l]

        if right == left:
            count += 1
        else:
            break
print(count)







### FIXED CODE ###

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

count = 0

xor_temp = 0
sum_temp = 0

r = 0
for l in range(n):
    while r < n and xor_temp^a[r]  == sum_temp + a[r]:
        xor_temp ^= a[r]
        sum_temp += a[r]
        r += 1

    xor_temp ^= a[l]
    sum_temp -= a[l]
    count += r - l

print(count)
### BUGGY CODE ###

# coding: utf-8


def rpow(x, y, z):
    i = 1
    a = x
    while i*i < y:
        a = (a*a) % z
        i *= 2
    return (a*pow(x, y-i, z)) % z if 0 < y else 1


def solve(*args: str) -> str:
    n, m, k = map(int, args[0].split())
    mod = 998244353

    ret = m*rpow(m-1, n-1, mod) % mod
    ncr = 1
    for i in range(1, k+1):
        ncr = ncr*(n-i)//i
        ret += m*rpow(m-1, n-1-i, mod)*ncr % mod

    return str(ret % mod)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


### FIXED CODE ###

# coding: utf-8


def bpow(x, y, z):
    a = 1
    for b in format(y, 'b'):
        a = (a*a) % z
        if b == '1':
            a = (a*x) % z
    return a


def solve(*args: str) -> str:
    n, m, k = map(int, args[0].split())
    mod = 998244353

    if m == 1 and n-1 == k:
        return str(1)

    ncr = 1
    p = m*bpow(m-1, n-1, mod) % mod
    ret = p
    inv = bpow(m-1, mod-2, mod)
    for i in range(1, k+1):
        ncr = (ncr * (n-i)*bpow(i, mod-2, mod)) % mod
        p = (p*inv) % mod
        ret += p*ncr % mod

    return str(ret % mod)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))
### BUGGY CODE ###

import sys

sys.setrecursionlimit(6500)

def find(n):
    if d[n]<0:
        return n
    else:
        d[n]=find(d[n])
        return d[n]

def union(a,b):
    a=find(a)
    b=find(b)
    if a==b:return False
    if d[a]<=d[b]:
        d[a]+=d[b]
        d[b]=a
    else:
        d[b]+=d[a]
        d[a]=b
    return True

def members(n):
    p=find(n)
    ans=[]
    for i in range(N):
        if find(i)==p:
            ans.append(i)
    return ans

N,M=map(int,input().split())
p=list(map(int,input().split()))

d=[-1]*N

for i in range(M):
    x,y=map(int,input().split())
    x,y=x-1,y-1
    union(x,y)

LN=[-1]*N
lis=[]
idx=0
for i in range(N):
    if LN[i]==-1:
        temp=members(i)
        lis.append(temp)
        for j in temp:
            LN[j]=idx
        idx+=1

ans=0
for i in range(N):
    for j in lis[LN[i]]:
        if i+1==p[j]:
            ans+=1
            break
print(ans)

### FIXED CODE ###

import sys

sys.setrecursionlimit(6500)

def find(n):
    if d[n]<0:
        return n
    else:
        d[n]=find(d[n])
        return d[n]

def union(a,b):
    a=find(a)
    b=find(b)
    if a==b:return False
    if d[a]<=d[b]:
        d[a]+=d[b]
        d[b]=a
    else:
        d[b]+=d[a]
        d[a]=b
    return True

def members(n):
    p=find(n)
    ans=[]
    for i in range(N):
        if find(i)==p:
            ans.append(i)
    return ans

def same(a,b):
    if find(a)==find(b):return True
    else:return False

N,M=map(int,input().split())
p=list(map(int,input().split()))

d=[-1]*N

for i in range(M):
    x,y=map(int,input().split())
    x,y=x-1,y-1
    union(x,y)

ans=0
for i in range(N):
    if same(i,p[i]-1):
        ans+=1
print(ans)
### BUGGY CODE ###

N, M = list(map(int, input().rstrip().split()))

st = []
tt = []

for i in range(M):
    s, t = list(map(int, input().rstrip().split()))
    if s == 1:
        st.append(t)
    
    if t == N:
        tt.append(s)

result = 'IMPOSSIBLE'
for s in st:
    if s in tt:
        result = 'POSSIBLE'
        break


print(result)
        


### FIXED CODE ###

N, M = list(map(int, input().rstrip().split()))

st = []
dic = {}

for i in range(M):
    s, t = list(map(int, input().rstrip().split()))
    if s == 1:
        st.append(t)
    
    if t == N:
        dic[s] = 0

result = 'IMPOSSIBLE'
for s in st:
    if s in dic:
        result = 'POSSIBLE'
        break


print(result)
### BUGGY CODE ###

K, N = map(int, input().split())
lis = list(map(int, input().split()))
dis=[]
for _ in range(N):
  p = lis.pop(0)
  lis.append(p)
  d = 0
  for i in range(N-1):
    if lis[i+1] > lis[i]:
      d += (lis[i+1]-lis[i])
    else:
      d += (K - lis[i]) + lis[i+1]
  dis.append(d)
print(min(dis))

### FIXED CODE ###

K, N = map(int, input().split())
lis = list(map(int, input().split()))
dis=[]
lis.append(lis[0])
for i in range(N):
  if lis[i+1] > lis[i]:
    dis.append(lis[i+1]-lis[i])
  else:
    dis.append((K - lis[i]) + lis[i+1])
print(sum(dis)-max(dis))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
#
# A - STring
#
# input
x_before = input()
x_after = ''
# calc
while True:
  x_after = x_before.replace('ST', '')
  if len(x_before) == len(x_after):
    break
  x_before = x_after
# output
print(len(x_after))

### FIXED CODE ###

# -*- coding: utf-8 -*-
#
# A - STring
#
# input
x = list(input())
n = 0
# calc
for i in range(len(x)):
  if x[i] == 'S':
    n += 1
  elif n>0:
    n -= 1
# output
print(n*2)
### BUGGY CODE ###

import math
N, K = map(int, input().split())
h = list(map(int, input().split()))

S = [0] * N
S[0] = 0

for i in range(1, N):
    value = math.inf
    for step in range(1, K + 1):
        if i - step < 0:
            break
        value = min(value, S[i - step] + abs(h[i] - h[i - step]))
    S[i] = value
print(S[N - 1])


### FIXED CODE ###

N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*(N)
dp[1]=abs(h[0]-h[1])
for i in range(2,N):
    dp[i]=min(dp[j]+abs(h[j]-h[i]) for j in range(max(0,i-K),i))
print(dp[N-1])
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
d = {}
for i in range(N):
  if A[i] in d:
    d[A[i]] += 1
  else:
    d[A[i]] = 1
#合計を求める
d_sum = {}
for i in set(A):
  d_sum[i] = int(d[i] *(d[i] - 1)/ 2)

#print(A, d,d_sum)
#print(sum(A), sum(d.values()))
for i in range(N):
  print(sum(d_sum.values()) - (d[A[i]] - 1))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
d = {}
d_sum = {}
for i in range(N):
  if A[i] in d:
    d[A[i]] += 1
    d_sum[A[i]] += d[A[i]] - 1
  else:
    d[A[i]] = 1
    d_sum[A[i]] = 0
#print(A, d,d_sum)
#print(sum(A), sum(d.values()))
ans = sum(d_sum.values())
for i in range(N):
  print(ans - (d[A[i]] - 1))
### BUGGY CODE ###

import pdb


def main():
    num = int(input())
    array = []
    tmp = input()
    for i in range(num):
        array.append(int(tmp.split()[i]))
        
    ans = 1
    div = 0
    prev = 0
    count = 0

    #pdb.set_trace()
    for tmp in array:
        if(count == 0):
            prev = tmp
            count = 1
            continue

        if prev < tmp and div == -1:
            ans += 1
            div = 0
            prev = tmp
            continue
        elif prev > tmp and div == 1:
            ans += 1
            div = 0
            prev = tmp
            continue

        if div == 0:
            if prev < tmp:
                div = 1
            elif prev > tmp:
                div = -1

        prev = tmp
        
    print(ans)

        
if __name__ == '__main__':
    main()


### FIXED CODE ###

import pdb


def main():
    num = int(input())
    array = []
    tmp = input()
    tmp = tmp.split()
    for i in range(num):
        array.append(int(tmp[i]))
        
    ans = 1
    div = 0
    prev = 0
    count = 0
    #pdb.set_trace()
    for tmp in array:
        count += 1
        if count == 1:
            prev = tmp
            continue

        if div == 0:
            if prev < tmp:
                div = 1
            elif prev > tmp:
                div = -1
        else:
            if prev < tmp and div == -1:
                ans += 1
                div = 0
            elif prev > tmp and div == 1:
                ans += 1
                div = 0
                
        prev = tmp
        
    print(ans)

        
if __name__ == '__main__':
    main()
### BUGGY CODE ###


MOD = 1000000007

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return a*b//gcd(a,b)

n = int(input())
a = list(map(int,input().split()))
all_lcm = 1
for i in range(n):
    all_lcm = lcm(all_lcm, a[i])
ans = 0
for i in range(n):
    ans += all_lcm//a[i]
print(ans%MOD)



### FIXED CODE ###


MOD = 1000000007

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return a//gcd(a,b)*b

n = int(input())
a = list(map(int,input().split()))
all_lcm = 1
for i in range(n):
    all_lcm = lcm(all_lcm, a[i])
ans = 0
for i in range(n):
    ans += all_lcm//a[i]
print(ans%MOD)