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

S = input()
Rindex = [i for i,x in enumerate(S) if x == 'R']
Rindex = Rindex[::-1]
Lindex = [i for i,x in enumerate(S) if x == 'L']
res = [0 for i in range(len(S))]
for i in range(len(S)):
    if S[i] == 'R':
        for l in Lindex:
            if l>i:
                a = l
                break
                
        c = a - i - 1
        if c%2 == 0:
            res[a - 1] += 1
        else:
            res[a] += 1
    else:
        for r in Rindex:
            if r<i:
                a = r
                break
        c = i - a - 1
        if c%2 == 0:
            res[a + 1] += 1
        else:
            res[a] += 1
for i,r in enumerate(res):
    if i != len(res) -1:
        print(r, end=" ")
    else:
        print(r)

### FIXED CODE ###

S = input()
Rnum = S.split('L')
Rnum = [len(i) for i in Rnum if i != '']
Lnum = S.split('R')
Lnum = [len(i) for i in Lnum if i != '']
res = [0]*len(S)
count = 0
for i,r in enumerate(Rnum):
    l = Lnum[i]
    res[r+count-1] = int((r+1)/2) + int(l/2)
    res[r+count] = int(r/2) + int((l+1)/2)
    count += r+l
for i,r in enumerate(res):
    if i!= len(res)-1:
        print(r,end=' ')
    else:
        print(r)
### BUGGY CODE ###

K=int(input())
a=0
i=1
l=[]
while True:
    a=a*10+7
    a%=K
    if a==0:
        print(i)
        break
    elif a in l:
        print('-1')
        break
    l.append(a)
    i+=1


### FIXED CODE ###

K=int(input())
if K%2==0 or K%5==0:
    print('-1')
    exit()
a=0
i=1
while True:
    a=(a*10+7)%K
    if a==0:
        print(i)
        break
    i+=1
### BUGGY CODE ###

N = int(input())
X = input()

d = {}
def popcount(s):
    if not s in d:
        cnt = 0
        for c in s:
            if c == '1':
                cnt += 1
        d[s] = cnt
    return d[s]

one = popcount(X)
for i in range(N):
    pop = one
    if X[i] == '1':
        pop -= 1
    else:
        pop += 1

    k = int(X, 2)
    bit = N-i-1
    if X[i] == '1':
        k -= 2**bit
    else:
        k += 2**bit
    #print(X[i], pop, k)
    ans = 0
    while k > 0:
        k %= pop
        pop = popcount(bin(k)[2:])
        ans += 1
        #print('  ', bin(k), pop, ans)
    print(ans)


### FIXED CODE ###

N = int(input())
X = input()
memo = [-1] * (N+1)
memo[0] = 0

def popcount(k):
    return bin(k).count('1')

def calc(k):
    pop = popcount(k)
    #print('  ', k, pop)
    key = k
    if memo[key] < 0:
        k %= pop
        if k == 0:
            memo[key] = 1
        else:
            memo[key] = calc(k) + 1
    return memo[key]

K = int(X, 2)
one = popcount(K)
if one == 0:
    K_MOD = K
elif one == 1:
    K_MOD   = 0
    K_MOD_M = K
else:
    K_MOD   = K % one
    K_MOD_M = K % (one-1)
K_MOD_P = K % (one+1)

T_M = [1]*(N+1)
T_P = [1]*(N+1)
for i in range(1,N+1):
    if one > 1:
        T_M[i] = (T_M[i-1]*2) % (one-1)
    T_P[i] = (T_P[i-1]*2) % (one+1)

for i in range(N):
    if X[i] == '1':
        pop = one - 1
        k = K_MOD_M - T_M[N-i-1]
    else:
        pop = one + 1
        k = K_MOD_P + T_P[N-i-1]

    if pop == 0:
        print(0)
    else:
        k %= pop
        print(calc(k)+1)
### BUGGY CODE ###

# coding: utf-8

Tak, Ao, K = (int(n) for n in input().split())
for i in range(K):
  if Tak > 0:
    Tak -= 1
  elif Ao > 0:
    Ao -= 1
print(Tak, Ao)

### FIXED CODE ###

# coding: utf-8
A, B, K = (int(n) for n in input().split())

if A <= K:
  K = K - A
  A = 0
else:
  A = A - K
  print(A, B)
  exit()
if B <= K:
  K = K - B
  B = 0
else:
  B = B - K
  print(A, B)
  exit()
print(A, B)
### BUGGY CODE ###

import numpy as np
N , K ,Q = map(int, input().split())
s = []
s = [int(input())-1 for _ in range(Q)]
initializer_list = np.full(N,K)
for i in s:
    tmp = initializer_list[i]
    initializer_list-=1
    initializer_list[i] = tmp

for i in initializer_list:
    if i > 0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

import numpy as np
N , K ,Q = map(int, input().split())
initializer_list = [0] * N
for _ in range(Q):
    i = int(input())-1
    initializer_list[i] += 1
    

[print('Yes') if (Q - initializer_list[i] < K) else print('No')  for i in range(N)]
### BUGGY CODE ###

import sys
from collections import defaultdict

def main():
    input = sys.stdin.readline
    S = str(input().strip())
    T = str(input().strip())

    if not set(T) <= set(S):
        return -1

    n = len(S)
    d = defaultdict(list)
    for i, s in enumerate(S, start=1):
        d[s].append(i)

    cnt = 0
    pos = 0
    for t in T:
        if pos >= max(d[t]):
            cnt += 1
            pos = d[t][0]
        else:
            left = 0
            right = len(d[t])
            while left < right:
                mid = (left + right) // 2
                np = d[t][mid]
                if np <= pos:
                    left = mid + 1
                else:
                    right = mid
            pos = d[t][left]

    return n * cnt + pos


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

import sys
from collections import defaultdict

def main():
    input = sys.stdin.readline
    S = str(input().strip())
    T = str(input().strip())

    if not set(T) <= set(S):
        return -1

    n = len(S)
    d = defaultdict(list)
    for i, s in enumerate(S, start=1):
        d[s].append(i)

    cnt = 0
    pos = 0
    for t in T:
        if pos >= d[t][-1]:
            cnt += 1
            pos = d[t][0]
        else:
            left = 0
            right = len(d[t])
            while left < right:
                mid = (left + right) // 2
                np = d[t][mid]
                if np <= pos:
                    left = mid + 1
                else:
                    right = mid
            pos = d[t][left]

    return n * cnt + pos


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

import sys
sys.setrecursionlimit(10 ** 8)

n, t = map(int, input().split())
a, b = [0] * n, [0] * n
for i in range(n):
  a[i], b[i] = map(int, input().split())

dp = [[[-1] * (t+1) for i in range(n)] for j in range(2)]
def dfs(i, l, d):
  if(i == n or l <= 0):
    return 0
  elif(dp[d][i][l] != -1):
    return dp[d][i][l]
  r = 0
  if(l > 0 and d > 0):
    r = max(r, b[i] + dfs(i+1, l - 1, d - 1))
  if(l >= a[i]):
    r = max(r, b[i] + dfs(i+1, l - a[i], d))
  r = max(r, dfs(i+1, l, d))
  dp[d][i][l] = r
  return dp[d][i][l]

print(dfs(0, t, 1))

### FIXED CODE ###

n, t = map(int, input().split())
a, b = [0] * n, [0] * n
for i in range(n):
  a[i], b[i] = map(int, input().split())

dp = [[[0] * (t+1) for i in range(n+1)] for j in range(2)]
for i in range(n):
  for d in range(2):
    for l in range(1,t+1):
      if(l < a[i]):
        dp[d][i+1][l] = max(dp[d][i][l], d*(b[i]+dp[0][i][l-1]))
      else:
        dp[d][i+1][l] = max(dp[d][i][l], b[i]+dp[d][i][l-a[i]], d*(b[i]+dp[0][i][l-1]))

print(dp[1][n][t])
### BUGGY CODE ###

N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
MOD = 10**9 + 7
dp = [[0] * (M + 2) for _ in range(N + 2)]
sdp = [[0] * (M + 2) for _ in range(N + 2)]
dp[0][0] = 1
sdp[1][1] = 1
for i in range(N + 1):
    for j in range(M + 1):
        if i - 1 >= 0 and j - 1 >= 0 and S[i - 1] == T[j - 1]:
            dp[i][j] = sdp[i][j]
        sdp[i + 1][j + 1] = sdp[i + 1][j] + sdp[i][j + 1] - sdp[i][j] + dp[i][j]
        sdp[i + 1][j + 1] %= MOD
        sdp[i + 1][j + 1] %= MOD
print(sdp[N + 1][M + 1])


### FIXED CODE ###

# dp[i][j] SとTの最後の文字を採用するような文字列の個数。これにより各DPテーブルの値が排反になる。元の文字列の最後を必ず採用するので
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
MOD = 10**9 + 7
dp = [[0] * (M + 2) for _ in range(N + 2)]
sdp = [[0] * (M + 2) for _ in range(N + 2)]
dp[0][0] = 1
sdp[1][1] = 1
for i in range(N + 1):
    for j in range(M + 1):
        if i - 1 >= 0 and j - 1 >= 0 and S[i - 1] == T[j - 1]:
            dp[i][j] = sdp[i][j]
        sdp[i + 1][j + 1] = sdp[i + 1][j] + sdp[i][j + 1] - sdp[i][j] + dp[i][j]
        sdp[i + 1][j + 1] %= MOD
        sdp[i + 1][j + 1] %= MOD
print(sdp[N + 1][M + 1])
### BUGGY CODE ###

N, W = list(map(lambda x: int(x), input().split()))
w = []
v = []
for i in range(N):
  line = input().split()
  w.append(int(line[0]))
  v.append(int(line[1]))
  
inf = 10**10
M = 100001
dp = [ [0] + [inf]*(M-1) for i in range(N) ]
dp[0][v[0]] = w[0] #最初の行

for i in range(1, N):
  for val in range(1, M):
    if val-v[i]>=0:
      dp[i][val] = dp[i-1][val-v[i]] + w[i]
    dp[i][val] = min(dp[i][val], dp[i-1][val])
    
#許されるvの最大値を見つける
for val in reversed(range(M)):
  if dp[N-1][val]<=W:
    print(val)
    break


### FIXED CODE ###

N, W = list(map(lambda x: int(x), input().split()))
w = []
v = []
for i in range(N):
  line = input().split()
  w.append(int(line[0]))
  v.append(int(line[1]))
  
inf = 10**10
M = sum(v)+1
dp = [ [0] + [inf]*(M-1) for i in range(N) ]
dp[0][v[0]] = w[0] #最初の行

lim = v[0]+1
for i in range(1, N):
  lim += v[i]
  for val in range(1, lim):
    if val-v[i]>=0:
      dp[i][val] = dp[i-1][val-v[i]] + w[i]
    dp[i][val] = min(dp[i][val], dp[i-1][val])
    
#許されるvの最大値を見つける
for val in reversed(range(M)):
  if dp[N-1][val]<=W:
    print(val)
    break
### BUGGY CODE ###

N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        bunshi = N * h * n
        bunbo = 4 * h * n - N * n - N * h
        if bunbo > 0 and bunshi % bunbo == 0:
            print("{} {} {}".format(h, n, bunshi // bunbo))
            exit()

### FIXED CODE ###

N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        waru = 4 * h * n - N * n - N * h
        if waru != 0:
            w = (N * h * n) / waru
            if w > 0 and int(w) / w == 1:
                print("{} {} {}".format(h, n, int(w)))
                exit()
### BUGGY CODE ###

import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N = int(input())

sum = 0
for i in range(1, N+1):
  for j in range(1, N+1):
    for k in range(1, N + 1):
      if i == j or j==k:
        hoge = gcd(i, k)
      elif i == k:
        hoge = gcd(j, k)
      elif i == j == k:
        hoge = 1
      else:
        hoge = gcd(i, j, k)
      sum+=hoge

print(sum)


### FIXED CODE ###

from math import gcd

N = int(input())

sum = 0
for i in range(1, N+1):
  for j in range(1, N + 1):
    x=gcd(i,j)
    for k in range(1, N + 1):
      hoge = gcd(x,k)
      sum+=hoge

print(sum)
### BUGGY CODE ###

MOD = 10**9 + 7

def prepare(n, MOD):
 
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs


k = int(input())
s = input()
n = len(s)
ans = 0

fact, inv = prepare(n+k, MOD)
for i in range(k+1):
    c25 = 1
    for j in range(i):
        c25 *= 25
        c25 % MOD
    f = fact[i+n-1] * inv[i] % MOD * inv[n-1] % MOD
    c25 *= f
    c25 %= MOD
    c26 = 1
    for h in range(k-i):
        c26 *= 26
        c26 % MOD
    ans += (c25 * c26 % MOD)
    ans %= MOD
print(ans)


### FIXED CODE ###

MOD = 10**9 + 7

def prepare(n, MOD):
 
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs


k = int(input())
s = input()
n = len(s)
ans = 0

l = k+n + 3
 
a25 = [1]
for i in range(l):
    a25.append((a25[-1] * 25) % MOD)
a26 = [1]
for i in range(l):
    a26.append((a26[-1] * 26) % MOD)

fact, inv = prepare(n+k, MOD)
for i in range(k+1):
    c25 = a25[i]
    f = fact[i+n-1] * inv[i] % MOD * inv[n-1] % MOD
    c25 *= f
    c25 %= MOD

    c26 = a26[k-i]
    ans += (c25 * c26 % MOD)
    ans %= MOD
print(ans)
### BUGGY CODE ###

def q4():
    import collections
    N = int(input())
    A = [int(i) for i in input().split()]

    def combinations_count(n, r):
        """ 組み合わせ総数を計算 """
        import math
        ret = 0 if n < r else math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
        return ret

    all_sum = 0  # 総数
    counter = collections.Counter(A)
    # all_sumを作成
    for v in counter.values():
        all_sum += combinations_count(v, 2)

    for i in range(N):
        cnt = counter[A[i]]  # i番目の値の出現回数を取得
        ans = all_sum - combinations_count(cnt, 2) + combinations_count(cnt - 1, 2)
        print(ans)

        
if __name__ == '__main__':
    q4()


### FIXED CODE ###

def q4():
    import collections
    N = int(input())
    A = [int(i) for i in input().split()]

    def n_C_2(n):
        """ n個から2個選ぶ組み合わせ総数を計算 """
        ret = 0 if n < 2 else n * (n - 1) / 2
        return ret

    all_sum = 0  # 総数
    counter = collections.Counter(A)
    # all_sumを作成
    for v in counter.values():
        all_sum += n_C_2(v)

    for i in range(N):
        cnt = counter[A[i]]  # i番目の値の出現回数を取得
        ans = all_sum - n_C_2(cnt) + n_C_2(cnt - 1)
        print(int(ans))


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

N = int(input())

power = 1
for n in range(1, N+ 1):
  power *= n
result = power % (pow(10, 9) + 7)
print(result)


### FIXED CODE ###

import math
N = int(input())

power = math.factorial(N)
result = power % (pow(10, 9) + 7)
print(result)
### BUGGY CODE ###

import bisect

h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
dh = {}
for i in range(h):
    dh[i] = []
    for j in range(w):
        if s[i][j] == "#":
            dh[i].append(j)
dw = {}
for i in range(w):
    dw[i] = []
    for j in range(h):
        if s[j][i] == "#":
            dw[i].append(j)
fw = [[0] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            if fw[i][j - 1]:
                fw[i][j] = 2
            else:
                fw[i][j] = 1
fh = [[0] * h for i in range(w)]
for i in range(w):
    for j in range(h):
        if s[j][i] == ".":
            if fh[i][j - 1]:
                fh[i][j] = 2
            else:
                fh[i][j] = 1
aw = [[0] * w for i in range(h)]
ah = [[0] * h for i in range(w)]
ans = 0
for i in range(h):
    a = dh[i]
    for j in range(w):
        if s[i][j] == "#":
            continue
        b = dw[j]
        if fw[i][j] == 1:
            c = bisect.bisect_left(a, j)
            if not a:
                wl = w
            else:
                if c == 0:
                    wl = a[0]
                elif c == len(a):
                    wl = w - a[-1] - 1
                else:
                    wl = a[c] - a[c - 1] - 1
        else:
            wl = aw[i][j - 1]
        if fh[j][i] == 1:
            d = bisect.bisect_left(b, i)
            if not b:
                hl = h
            else:
                if d == 0:
                    hl = b[0]
                elif d == len(b):
                    hl = h - b[-1] - 1
                else:
                    hl = b[d] - b[d - 1] - 1
        else:
            hl = ah[j][i - 1]
        aw[i][j] = wl
        ah[j][i] = hl
        ans = max(ans, wl + hl - 1)
print(ans)

### FIXED CODE ###

h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
hc = [[0] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            if j > 0:
                hc[i][j] = hc[i][j - 1] + 1
            else:
                hc[i][j] = 1
for i in range(h):
    for j in range(w - 1, -1, -1):
        if s[i][j] == ".":
            if j < w - 1:
                if hc[i][j] < hc[i][j + 1]:
                    hc[i][j] = hc[i][j + 1]
wc = [[0] * h for i in range(w)]
for i in range(w):
    for j in range(h):
        if s[j][i] == ".":
            if j > 0:
                wc[i][j] = wc[i][j - 1] + 1
            else:
                wc[i][j] = 1
for i in range(w):
    for j in range(h - 1, -1, -1):
        if s[j][i] == ".":
            if j < h - 1:
                if wc[i][j] < wc[i][j + 1]:
                    wc[i][j] = wc[i][j + 1]
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, hc[i][j] + wc[j][i] - 1)
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
p = [0]*n
q = [0]*n
a.sort()
b.sort()
c.sort()
k = 0
for i in range(n):
  while k<n:
    if a[k]<b[i]:
      k += 1
    else:
      break
  p[i] = k
k = 0
for i in range(n):
  while k<n:
    if b[k]<c[i]:
      k += 1
    else:
      break
  q[i] = sum(p[:k])
print(sum(q))


### FIXED CODE ###

n = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))
p = [0]*n
q = [0]*n
k = 0
for i in range(n):
  while k<n:
    if a[k]<b[i]:
      k += 1
    else:
      break
  p[i] = k
k = 0
s = 0
ans = 0
for i in range(n):
  while k<n:
    if b[k]<c[i]:
      s += p[k]
      k += 1
    else:
      break
  ans += s
print(ans)
### BUGGY CODE ###

n=int(input())
s=input()
dp=[[0]*n for _ in range(n)]
ans=0
for i in range(n-1,-1,-1):
    for j in range(n-1,i,-1):
        if s[i]==s[j]:
            dp[i][j]=dp[i+1][j+1]+(i+1+dp[i+1][j+1]!=j+1) if j<n-1 else 1
    ans=max(ans,max(dp[i]))
print(ans)

### FIXED CODE ###

n=int(input())
s=input()
l=0
r=n//2
while r-l>=1:
    m=(r+l+1)//2
    d={}
    flg=False
    for i in range(n-m+1):
        t=s[i:i+m]
        if t in d:
            if d[t]+m-1<i:
                flg=True
                break
        else:
            d[t]=i
    if flg:
        l=m
    else:
        r=m-1
print(l)
### BUGGY CODE ###

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
res = 0
chk = -1
a = []
for i,j in enumerate(list(t)):
	if j == "s":
		if i in a:
			continue
		res += r
		chk = i+k
		a.append(chk)
chk = -1
a = []
for i,j in enumerate(list(t)):
	if j == "p":
		if i in a:
			continue
		res += s
		chk = i+k
		a.append(chk)
chk = -1
a = []
for i,j in enumerate(list(t)):
	if j == "r":
		if i in a:
			continue
		res += p
		chk = i+k
		a.append(chk)
print (res)

### FIXED CODE ###

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
res = 0
for i in range(n):
	if t[i] == t[i-k] and i >= k:
		t[i] = "X"
	if t[i] == "s":
		res += r
	if t[i] == "p":
		res += s
	if t[i] == "r":
		res += p
print (res)
### BUGGY CODE ###

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

uv = {}
for i in range(M):
    u, v = map(int, input().split())
    if not u in uv:
        uv[u] = [v]
    else:
        uv[u].append(v)


S, T = map(int, input().split())

b = [False] * (10**5+1)
us = [S]
b[S] = True
cnt = 0
while us:
    cnt += 1
    for i in range(3):
        tmpus = []
        for u in us:
            if u in uv:
                for v in uv[u]:
                    tmpus.append(v)
        us = tmpus

    if T in us:
        print(cnt)
        break

    tmpus = []
    for u in us:
        if b[u] is False:
            b[u] = True
            tmpus.append(u)
    us = tmpus


if not T in us:
    print(-1)


### FIXED CODE ###

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

uv = {}
for i in range(M):
    u, v = map(int, input().split())
    if not u in uv:
        uv[u] = [v]
    else:
        uv[u].append(v)


S, T = map(int, input().split())

b = [[False] * (10**5+1) for i in range(3)]
us = [S]
b[-1][S] = True
cnt = 0
while us:
    cnt += 1
    for i in range(3):
        tmpus = []
        for u in us:
            if u in uv:
                for v in uv[u]:
                    if b[i][v] is False:
                        b[i][v] = True
                        tmpus.append(v)
        us = tmpus

    if T in us:
        print(cnt)
        break

if not T in us:
    print(-1)
### BUGGY CODE ###

n = int(input())
w_l = [input() for _ in range(n)]

d = {}

max_v = 0
for w in w_l:
    if d.get(w, 0) == 0:
        d[w] = 1
    else:
        d[w] += 1

max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]

max_k_list.sort()

for k in max_k_list:
    print(k)




### FIXED CODE ###

import collections


n = int(input())
w_l = [input() for _ in range(n)]

counter = collections.Counter(w_l)

c_l = counter.most_common()
max_v = c_l[0][1]
ans_l = []
for i in range(len(c_l)):
    word, num = c_l[i]
    if max_v != num:
        break
    ans_l.append(word)

ans_l.sort()
for ans in ans_l:
    print(ans)
### BUGGY CODE ###

n,a=int(input()),list(map(int,input().split()));b=[0]*3;dp=[[[0]*(n+1) for i in range(n+1)]for i in range(n+1)];flag=[[[False]*(n+1) for i in range(n+1)]for i in range(n+1)];flag[0][0][0]=True
for i in a:b[i-1]+=1
def d(a,b,c):
  if flag[a][b][c]:return dp[a][b][c]
  p=1;flag[a][b][c]=True
  if a>0:p+=d(a-1,b,c)*(a/n)
  if b>0:p+=d(a+1,b-1,c)*(b/n)
  if c>0:p+=d(a,b+1,c-1)*(c/n)
  dp[a][b][c]=p/(1-((n-a-b-c)/n));return dp[a][b][c]
print(d(b[0],b[1],b[2]))

### FIXED CODE ###

n,a=int(input()),map(int,input().split());c=[0]*3
for i in a:c[i-1]+=1
x,y,z=c;dp=[[[None]*(z+2) for i in range(n-x+2)]for i in range(n+2)];dp[0][0][0]=0
for k in range(z+1):
  for j in range(n-x-k+1):
    for i in range(n-k-j+1):
      if i+j+k:dp[i][j][k]=((dp[i-1][j][k]*i if i else 0)+(dp[i+1][j-1][k]*j if j else 0)+(dp[i][j+1][k-1]*k if k else 0)+n)/(i+j+k)
print(dp[x][y][z])
### BUGGY CODE ###

import numpy as np

##################################################################
def main():
    Input = [input() for i in range(2)]
    N = int(Input[0])
    L = list(map(int,Input[1].split()))
    L.sort()
    L = np.array(L)
    ans = 0
    for i1 in range(0,N-2):
        a = L[i1]
        for i2 in range(i1+1,N-1):
            b = L[i2]
            ans += sum(L[i2+1:N]<a+b)
    print(ans)



if __name__ == "__main__":
    main()


### FIXED CODE ###

import bisect
##################################################################
def main():
    Input = [input() for i in range(2)]
    N = int(Input[0])
    L = list(map(int,Input[1].split()))
    L.sort()
    ans = 0
    for i1 in range(0,N-2):
        a = L[i1]
        for i2 in range(i1+1,N-1):
            b = L[i2]
            ans += bisect.bisect_left(L, a+b) - i2 - 1
    print(ans)



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

import sys
input = sys.stdin.readline

N,M = map(int,input().split())
matrix = [[0]*N for i in range(N)]
for _ in range(M):
    x,y = map(int,input().split())
    x -= 1; y -= 1
    matrix[x][y] = 1

dp = [-1]*N

def rec(nodes):
    if dp[nodes] != -1:
        return dp[nodes]
    dp[nodes] = 0
    for ne,bit in enumerate(matrix[nodes]):
        if bit == 0:continue
        option = rec(ne)+1
        if dp[nodes] < option:
            dp[nodes] = option
    return dp[nodes]

ans = 0
for i in range(N):
    res = rec(i)
    if ans < res:
        ans = res
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N,M = map(int,input().split())
ad = [[] for i in range(N)]
for _ in range(M):
    x,y = map(int,input().split())
    x -= 1; y -= 1
    ad[x].append(y)

dp = [-1]*N

def rec(nodes):
    if dp[nodes] != -1:
        return dp[nodes]
    res = 0
    for ne in ad[nodes]:
        option = rec(ne)+1
        if res < option:
            res = option
    dp[nodes] = res
    return dp[nodes]

ans = 0
for i in range(N):
    res = rec(i)
    if ans < res:
        ans = res
print(ans)