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

import math

N = int(input())
s = [""]*N
a =[[0]*26 for i in range(N)]
b =[""]*N

cn =ord("a")

for i in range(N):
    s[i] = list(input())
    for j in range(26):
        a[i][j] = s[i].count(chr(cn+j))
    b[i] ="".join(str(a[i]))

b.sort()
c = 0
ans =0

for i in range(N-1):
    if b[i]==b[i+1]:
        c +=1
    else:
        if c !=0:
            ans=ans + math.factorial(c+1)/(math.factorial(2)*math.factorial(c+1-2))
            c = 0


if c !=0:
    ans = ans + math.factorial(c+1)/(math.factorial(2)*math.factorial(c+1-2))
    

print(int(ans))


### FIXED CODE ###

import math

N = int(input())
s = [[""]*10 for i in range(N)]
a =[[0]*26 for i in range(N)]
b =[""]*N

cn =ord("a")

for i in range(N):
    s[i] = list(input())
    s[i].sort()
    b[i] ="".join(s[i])

b.sort()
c = 0
ans =0

for i in range(N-1):
    if b[i]==b[i+1]:
        c +=1
    else:
        if c !=0:
            ans=ans + math.factorial(c+1)/(math.factorial(2)*math.factorial(c+1-2))
            c = 0


if c !=0:
    ans = ans + math.factorial(c+1)/(math.factorial(2)*math.factorial(c+1-2))
    

print(int(ans))
### BUGGY CODE ###

a=input()
num=len(a)
mod_map={0:1}
mod_list=[1]+[0]*2019
moji_int=0
Sn=[0]*(num+1)
tens=[1]*(num+1)
for i in range(-1,-num-1,-1):
    tens[-i]=tens[-i-1]*10
    tmp=int(a[i])*(tens[-i-1]%2019)
    Sn[-i]=(Sn[-i-1]+tmp%2019)%2019
    mod=Sn[-i]
    mod_list[mod]+=1

res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)


### FIXED CODE ###

a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)
### BUGGY CODE ###

import sys
from operator import itemgetter
N,M = map(int,input().split())
A = [0] * M
#B = [0] * M
for i in range(M):
    A[i] = list(map(int,input().split()))
    if A[i][0] > A[i][1]:
        A[i][0],A[i][1] = A[i][1],A[i][0]
A = sorted(A, key = itemgetter(0))        
C = [set()]
if M != 0:
    C[0].add(A[0][0])
    C[0].add(A[0][1])
else:
    print(1)
    sys.exit()
for i in range(1,M):
    for j in range(len(C)):
        if A[i][0] in C[j]:
            C[j].add(A[i][1])
            continue
        elif A[i][1] in C[j]:
            C[j].add(A[i][0])
            continue
        else:
            C.append({A[i][0],A[i][1]})
            continue
ans = 0
for j in range(len(C)):
    if len(C[j]) > ans:
        ans = len(C[j])
print(ans)

### FIXED CODE ###

class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
    
N, M = map(int,input().split())
A = [None] * M
B = [None] * M
for i in range(M):
    A[i], B[i] = map(int,input().split())
uf = UnionFind(N)
for j,h in zip(A,B):
    uf.Unite(j,h)
print(min(uf.root)*(-1))
### BUGGY CODE ###

import math
n = int(input())
a = 0
for i in range(0,n):
  for j in range(0,n):
    for k in range(0,n):
      gcd1 = math.gcd(i+1,j+1)
      gcd2 = math.gcd(gcd1,k+1)
      a = a + gcd2
      
print(a)

### FIXED CODE ###

import math
n = int(input())
a = 0
for i in range(0,n):
  for j in range(0,n):
    gcd1 = math.gcd(i+1,j+1)
    
    for k in range(0,n):
      gcd2 = math.gcd(gcd1,k+1)
      a = a + gcd2
      
print(a)
### BUGGY CODE ###

N, K = map(int, input().split())
S = set()
for _ in range(K):
    l, r = map(int, input().split())
    S = S | set(range(l, r + 1))
mod = 998244353

dp = [0 for _ in range(3 * N)]
for s in S:
    dp[s + 1] = 1
for i in range(1, N + 1):
    for s in S:
        dp[i] += dp[i - s]
        dp[i] %= mod
print(dp[N] % mod)

### FIXED CODE ###

N, K = map(int, input().split())
S = []
for _ in range(K):
    S.append(list(map(int, input().split())))
mod = 998244353

dp = [0 for _ in range(2 * N + 1)]
dp[1] = 1

cum = [0 for _ in range(2 * N + 1)]
cum[1] = 1

for i in range(N):
    for l, r in S:
        dp[i + 1] += cum[i - l + 1] - cum[i - r]
        dp[i + 1] %= mod
    cum[i + 1] = cum[i] + dp[i + 1]
    cum[i + 1] %= mod
print(dp[N])
### BUGGY CODE ###

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, = map(int,readline().split())
vw = [(0,0)]+[tuple(map(int,readline().split())) for _ in range(n)]

A = 10
N = min(1<<A,n+1)

memo = [None for _ in range(N)]
L = 10**5+1
memo[0] = [0]*L

for i in range(1,N):
    m = memo[i>>1][:]
    v,w = vw[i]    
    for j in range(L-1,w-1,-1):
        if m[j] < m[j-w]+v:
            m[j] = m[j-w]+v
    memo[i] = m

q, = map(int,readline().split())
for _ in range(q):
    u,l = map(int,readline().split())

    m = u.bit_length() - A
    if m<0: m=0
    dv = [0]*(1<<m)
    dw = [0]*(1<<m)
    for i in range(m):
        v,w = vw[u]
        for j in range(1<<i):
            dv[j+(1<<i)] = dv[j]+v
            dw[j+(1<<i)] = dw[j]+w
        u >>= 1
    
    ans = 0
    for v,w in zip(dv,dw):
        if w <= l:
            val = memo[u][l-w] + v
            if val > ans: ans = val
    print(ans)

        


### FIXED CODE ###

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

#n,k,*a = map(int,read().split())

n, = map(int,readline().split())
vw = [[0,0]]+[list(map(int,readline().split())) for _ in range(n)]

def merge(av,aw,bv,bw):
    la,lb = len(aw),len(bw)
    rv = [0]*(la+lb)
    rw = [0]*(la+lb)
    ia = ib = 0
    for i in range(la+lb):
        if ib==lb or (ia < la and aw[ia] < bw[ib]):
            rv[i] = av[ia]
            rw[i] = aw[ia]
            ia += 1
        else:
            rv[i] = bv[ib]
            rw[i] = bw[ib]
            ib += 1
    return rv,rw

A = 10
N = min(1<<A,n+1)
memov = [[] for _ in range(N)]
memow = [[] for _ in range(N)]

memov[0] = [0]
memow[0] = [0]

#from itertools import acumulate
for i in range(1,N):
    v,w = vw[i]
    m2v = [v+v1 for v1 in memov[i>>1]]
    m2w = [w+w1 for w1 in memow[i>>1]]
    memov[i],memow[i] = merge(memov[i>>1],memow[i>>1],m2v,m2w)

    #memov[i] = list(accumulate(memov[i],max))
    for j in range(1,len(memov[i])):
        memov[i][j] = max(memov[i][j-1],memov[i][j])
    
def solve(lstv,lstw,dv,dw,l):
    ans = 0
    idx = len(lstw)-1
    #print(lstv,lstw,dv,dw,l)
    for v,w in zip(dv,dw):
        while idx >= 0 and lstw[idx] + w > l:
            idx -= 1
        if idx >= 0 and v+lstv[idx] > ans:
            ans = v+lstv[idx]
    print(ans)        
 
 

q, = map(int,readline().split())
for _ in range(q):
    u,l = map(int,readline().split())

    dv = [0]
    dw = [0]
    while u >= N:
        v,w = vw[u]
        m2v = [v+v1 for v1 in dv]
        m2w = [w+w1 for w1 in dw]
        dv,dw = merge(dv,dw,m2v,m2w)
        u >>= 1
    
    #for j in range(1,len(dv)):
    #    dv[j] = max(dv[j-1],dv[j])
    
    solve(memov[u],memow[u],dv,dw,l)

#print(memov)
#print(memow)
### BUGGY CODE ###

def compare(a, A):
    R=0
    for i in range(0, len(A)):
        if(a==A[i]):
            R+=1
        elif(a<A[i]):
            break
    return R

def result(R,a):
    if(R==a):
        return 0
    elif(a<R):
        return R-a
    return R

N = int(input())

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

R=0
R+=result(compare(a[0],a),a[0])
T=compare(a[0],a)

for i in range(1, N):
    if(a[i] != a[i-1]):
        R+=result(compare(a[i],a[T:]),a[i])
        T+=compare(a[i],a)


print(R)


### FIXED CODE ###

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

a.sort()
a.append(0)

T=[]
j=0
t=0
s=0
for i in range(N):
    j+=1
    if a[i] != a[i+1]:
        if j-s > a[i]:
            t+=(j-s)-a[i]
        elif j-s < a[i]:
            t += j-s
        s=j

print(t)
### BUGGY CODE ###

import math
n = int(input())
r = list(map(int,input().split()))

lim = math.pow(10,18)

for i in range(n):
    if i == 0:
        x = r[i]
    else:
        x = x * r[i]

if x > lim:
    x = -1

print(int(x))

### FIXED CODE ###

import math
n = int(input())
r = list(map(int,input().split()))

lim = math.pow(10,18)

for i in range(n):
    if i == 0:
        x = r[i]
    else:
        x = x * r[i]

    if x > 1000000000000000000:
        break

if x > 1000000000000000000:
    x = -1

if 0 in r:
    x = 0

print(math.floor(x))
### BUGGY CODE ###

def read():
    N = int(input())
    As = list(map(int, input().split(' ')))
    return N, As


def func(N, As):
    ans = 0
    for i in range(N):
        ai = As[i]
        for j in range(i + 1, N):
            aj = As[j]
            ans += ai * aj
    return ans % (10 ** 9 + 7)

if __name__ == '__main__':
    N, As = read()
    print(func(N, As))


### FIXED CODE ###

def read():
    N = int(input())
    As = list(map(int, input().split(' ')))
    return N, As


def func(N, As):
    ans = 0
    s = As[-1]
    for i in range(N - 1):
        t = As[-1 * (i+2)]
        ans += s * t
        s += t
    return ans % (10 ** 9 + 7)

if __name__ == '__main__':
    N, As = read()
    print(func(N, As))
### BUGGY CODE ###

N=int(input()) 
A=list(map(int, input().split())) 
k =  len(bin(max(A))[2:])
mod = 10**9+7
c = [0]*k
 
for i in A:
  bit = bin(i)[2:].zfill(k)
  for j in range(k):
    if bit[j] == '1':
      c[-1-j] +=1
      
ans = 0
for i in range(k):
  ans = (ans +(2**i)*(c[i]*(N-(c[i]))))%mod
  
print(ans)
  

### FIXED CODE ###

N=int(input()) 
import math
A=list(map(int, input().split())) 
k =  len(bin(max(A))[2:])
mod = 10**9+7

c = [0]*k

for i in A:
  bit = bin(i)[2:].zfill(k)
  for j in range(k):
    if bit[j] == '1':
      c[-1-j] +=1
      
ans = 0
for i in range(k):
  ans = (ans +(2**i)*(c[i]*(N-(c[i]))))%mod
  
print(ans)
### BUGGY CODE ###

def main():
    import sys
    import numpy as np
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    S = input().strip()
    Sn = np.array([int(x) for x in S])
    N = len(S)
    ans = 0
    if N < 4:
        print(0)
        exit()
    for i in range(N-3):
        # print('i = {}'.format(i))
        T = Sn[i:].cumsum()
        NT = len(T)
        for j in range(3, NT):
            # print('  j = {}'.format(j))
            if T[j] % 3 == 0:
                if int(S[i:i+j+1]) % 2019 == 0:
                    # print(S[i:i+j+1])
                    ans += 1

    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    from collections import Counter
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    S = [int(x) for x in input().strip()]
    N = len(S)
    ans = 0
    l = [0] * (N + 1)
    p = 1
    cumsum = [0] * (N + 1)
    for i in range(N-1, -1, -1):
        l[i] = (S[i] * p) % 2019
        p *= 10
        p %= 2019
    for i in range(N-1, -1, -1):
        cumsum[i] = (l[i] + cumsum[i+1]) % 2019
    cumsum = Counter(cumsum)
    for i in range(0, 2019):
        ans += (cumsum[i] * (cumsum[i] - 1)) // 2

    print(ans)

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

from math import gcd
from functools import reduce
k = int(input())

l = [[a,b,c] for a in range(1,k+1) for b in range(1,k+1) for c in range(1,k+1)]
#print(sum(reduce(gcd,l)))
ans = 0
for i in l:
  ans += reduce(gcd,i)
print(ans)

### FIXED CODE ###

from math import gcd
k = int(input())

ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    x = gcd(i,j)
    for l in range(1,k+1):
      ans += gcd(x,l)
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
arr = [0]*(max(a)+1)

for i in a:
  arr[i]+=1
  tmp = i
  while (tmp+i)<=max(a):
    tmp += i
    if arr[tmp] !=0:
      arr[tmp] =2
    else:
      arr[tmp] +=1

cnt = 0
for i in a:
  if arr[i] ==1:
    cnt += 1
print(cnt)
      
  

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
m=max(a)
alist=[0]*(m+1)
for i in a:
  for j in range(i,m+1,i):
    alist[j]+=1
cnt=0
for i in a:
  if alist[i]==1:
    cnt+=1
print(cnt)
### BUGGY CODE ###

A,B=map(int,input().split())
def cf(x1,x2):
    cf=[]
    cf.append(1)
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
def gcd(a, b):
  while b!=0:
    a, b = b, a % b
  return a 

mod=cf(A,B)
ans=0
ans_list=[]
ans_list.append(1)
if len(mod)==1 :
  ans=1
else:
  for i in range(1,len(mod)):
    t=0
    for v in range(len(ans_list)):
      t+=1
      if gcd(mod[i],ans_list[v])!=1 :
        break
      if t==len(ans_list):
        ans_list.append(mod[i])
ans=len(ans_list)
print(ans)

### FIXED CODE ###

A,B=map(int,input().split())

import math

def tn(n):
  m=n
  factor=[]
  tmp=int(math.sqrt(n))+1
  for num in range(2,tmp):
    t=0
    while n%num==0:
      n//=num
      if t==0:
        factor.append(num)
        t=1
  if factor==[]:
    factor.append(m)
  factor.append(1)
  factor.append(n)
  return factor

listA=tn(A)
listB=tn(B)
anslist=set(listA) & set(listB)
ans=len(anslist)
print(ans)
### BUGGY CODE ###

x, y, m = map(int,input().split())
mat = []
r = [0]*x
c = [0]*y
smx = 0
smy = 0
for _ in range(m):
    p, q = map(int,input().split())
    p -= 1
    q -= 1
    mat.append((p,q))
    r[p] += 1
    c[q] += 1
    smx = max(smx,r[p])
    smy = max(smy,c[q])
xs = []
ys = []
for i in range(x):
    if smx == r[i]: xs.append(i)
for i in range(y):
    if smy == c[i]: ys.append(i)

ans = smx + smy - 1

for h in xs:
    for w in ys:
        if (h, w) in mat: continue
        print(ans + 1)
        exit()
print(ans)


### FIXED CODE ###

x, y, m = map(int,input().split())
mat = set()
r = [0]*x
c = [0]*y
smx = 0
smy = 0
for _ in range(m):
    p, q = map(int,input().split())
    p -= 1
    q -= 1
    mat.add((p,q))
    r[p] += 1
    c[q] += 1
    smx = max(smx,r[p])
    smy = max(smy,c[q])
xs = []
ys = []
for i in range(x):
    if smx == r[i]: xs.append(i)
for i in range(y):
    if smy == c[i]: ys.append(i)

ans = smx + smy - 1

for h in xs:
    for w in ys:
        if (h, w) in mat: continue
        print(ans + 1)
        exit()
print(ans)
### BUGGY CODE ###

X=input()
A=len(X)
B=X.count("S")
if B>A-B:
  K=A-B
else:
  K=B
for i in range(K):
  X=X.replace("ST","")
print(len(X))

### FIXED CODE ###

L=0
R=0
X=list(input())
A=len(X)
for i in range(A):
  if X[i]=="S":
    R=R+1
  elif X[i]=="T":
    if R!=0:
      L=L+1
      R=R-1
print(A-2*L)
### BUGGY CODE ###

import itertools

A, B, M = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

x = [0] * M
y = [0] * M
c = [0] * M

ans = []

for i in range(M):
    x[i], y[i], c[i] = [int(k) for k in input().split()]
for i, j in itertools.product(a, b):
    ans.append(i + j)

for i in range(M):
    ans.append(a[x[i]-1] + b[y[i]-1] - c[i])

print(min(ans))

### FIXED CODE ###

A, B, M = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

x = [0] * M
y = [0] * M
c = [0] * M

ans = []
ans.append(min(a) + min(b))
for i in range(M):
    x[i], y[i], c[i] = [int(k) for k in input().split()]

for i in range(M):
    ans.append(a[x[i] - 1] + b[y[i] - 1] - c[i])

print(min(ans))
### BUGGY CODE ###

n = int(input())
c = input()
c = [char for char in c]

r_idx, w_idx = [], []
for j in range(n):
    if c[j] == "R":
        r_idx.append(j)
    elif c[j] == "W":
        w_idx.append(j)

ans = 0
for i in range(len(c) - len(w_idx)):
    if i in w_idx:
        ans += 1

print(ans)

### FIXED CODE ###

n = int(input())
c = input()
c = [char for char in c]

ans = 0
for i in range(c.count("R")):
    if c[i] == "W":
        ans += 1

print(ans)
### BUGGY CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]

if N == 2:
    print("\n".join(map(str, A[::-1])))
else:
    for i in range(N):
        if i == N - 1:
            print(max(A[:-1]))
        else:
            print(max(A[:i] + A[i+1:]))


### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]

if N == 2:
    print("\n".join(map(str, A[::-1])))
else:
    a = sorted(A)
    maxv1 = a[-1]
    maxi1 = A.index(maxv1)
    maxv2 = a[-2]

    for i in range(N):
        if i == maxi1:
            print(maxv2)        
        else:
            print(maxv1)
### BUGGY CODE ###

import fractions
K=int(input())
ans=0
A=0

for n in range(1,K+1):
    for m in range(1,K+1):
      gcd1=fractions.gcd(n,m)
      for l in range(1,K+1):
          A=fractions.gcd(gcd1,l)   
          ans+=A
print(ans)

### FIXED CODE ###


import math
K=int(input())
ans=0
A=0

for n in range(1,K+1):
    for m in range(1,K+1):
        x=math.gcd(n,m)
        for l in range(1,K+1):
            A=math.gcd(x,l)    
            ans+=A
            
print(ans)
### BUGGY CODE ###

K = int(input())

def calculate(k):

    res = 1

    n = 7

    if k % 2 == 0:
        print(-1)
        return

    if k % 5 == -1:
        print(-1)
        return

    while n % k > 0:
        n = n % k
        n = n * 10 + 7
        res += 1

    print(res)

calculate(K)

### FIXED CODE ###

K = int(input())

def calculate(k):

    if k % 2 == 0:
        print(-1)
        return

    if k % 5 == 0:
        print(-1)
        return

    res = 1

    m = (((10 ** res) - 1) // 9) * 7


    while m % k > 0:
        res += 1
        m = m % k
        m = m * 10 + 7

    print(res)


calculate(K)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
def main():
    N = int(readline())
    A = np.zeros(N+1, dtype=np.int64)
    A[1:] = np.array(readline().split(), np.int64)
    table = np.zeros(N+1, dtype=np.int64) 
    for i in np.arange(1,N+1, dtype=np.int64)[::-1]:
        table[i] = (table[::i].sum()+A[i])%2

    print(table.sum())
    for i in range(N):
        if table[i+1]:
            print(i+1, end=' ')
if __name__ == '__main__':
    main()

### FIXED CODE ###

#python3

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    b = [0 for _ in range(n)]
    for i in reversed(range(1, n+1)):
        s = 0
        j = i + i
        while j <= n: 
            s ^= b[j-1]
            j += i
        b[i-1] = s^a[i-1]
    
    m = sum(b)
    print(m)
    for i in range(n):
        if b[i] == 1:
            if i == n-1:
                print(i+1)
            else:
                print(i+1, end=' ')
        
main()
### BUGGY CODE ###

# Given is a sequence of N integers A1,[ldots],AN.

# Find the (multiplicative) inverse of the sum of the inverses of these numbers,  1	 1	A1 +[ldots]+ 1	AN  .

def gcd(a, b):
    while b > 0:
        if a >= b:
            a -= b
        else:
            a, b = b, a
    return a

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

input() # N; >0
resistances = [int(a) for a in input().split()]
lcm_r = 1
for r in resistances:
    lcm_r = lcm(r, lcm_r)
# numerator is lcm of resistances
# denominator is sum of lcm/resistance for resistance in resistances
num = lcm_r
denominator = 0
for r in resistances:
    denominator += lcm_r//r
print(num/denominator)

### FIXED CODE ###

n=int(input())
a=[int(i) for i in input().split()]
ans=0.0
d=0
for i in a:
    d=1/i
    ans+=d
print(1/ans)
### BUGGY CODE ###

import sys
import numpy as np

input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
B = 0
extend = A.extend
for _ in range(m):
    b, c = map(int, input().split())
    B += b
    extend([c]*b)

A.sort()
del A[0:B]
print(np.sum(A))

### FIXED CODE ###

import sys

input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(m)]
BC.sort(key=lambda x: -x[1])

maxi = n*2
extend = A.extend
[extend([ls[1]] * ls[0]) for ls in BC if len(A) <= maxi]
A.sort(reverse=True)

print(sum(A[:n]))
### BUGGY CODE ###

X, Y, Z, K = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
sum = 0
ans = []
ans2 = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
for i in range(X):
    for j in range(Y):
        sum = A[i] + B[j]
        ans.append(sum)
ans.sort(reverse=True)

for i in range(min(3000,len(ans))):
    for j in range(Z):
        sum = ans[i] + C[j]
        ans2.append(sum)
ans2.sort(reverse=True)

for l in range(K):
    print(ans2[l])


### FIXED CODE ###

X, Y, Z, K = map(int,input().split())
A = sorted(list(map(int, input().split())),reverse=True)
B = sorted(list(map(int, input().split())),reverse=True)
C = sorted(list(map(int, input().split())),reverse=True)

ans = []

for i in range(X):
    for j in range(Y):
        if (i+1)*(j+1) > K:
            break
        for t in range(Z):
            if (i+1)*(j+1)*(t+1) > K:
                break
            ans.append(A[i]+B[j]+C[t])
ans.sort(reverse=True)

for l in range(K):
    print(ans[l])
### BUGGY CODE ###

N, M = list(map(int, input().split()))
A=[0] * M
B=[0] * M

import math

for i in range(M):
  A[i], B[i] = list(map(int, input().split()))

  
island_dict={i+1:i+1 for i in range(N)} #島が属するグループ
group_dict={i+1:[i+1] for i in range(N)} #グループに属する島

answer = [0] * M
answer[-1] = math.factorial(N) // (math.factorial(N-2)*2)

  
for i in range(M)[:0:-1]:
  if island_dict[A[i]] == island_dict[B[i]]:
    answer[i-1] = answer[i]
  else:
    groupA = island_dict[A[i]]
    groupB = island_dict[B[i]] #グループ合併, groupB消滅
    NA = len(group_dict[groupA])
    NB = len(group_dict[groupB])
    
    for j in group_dict[groupB]:
      island_dict[j] = groupA
   
    group_dict[groupA] = group_dict[groupA] + group_dict[groupB]
    group_dict[groupB] = []
    answer[i-1] = answer[i] - NA*NB

#print(answer)

for i in range(M):
  print(answer[i])
    
    

### FIXED CODE ###

N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

roots = [(i,1) for i in range(N+1)] # root, num_islands_in_group

inconveniences = [0]*(M+1)
inconveniences[-1] = N*(N-1)//2 #すべての橋が崩落するとNC2

def find_root(a, roots=roots):
  if roots[a][0] == a:
    return roots[a]
  else:
    roots[a] = find_root(roots[a][0])
  return roots[a]

def reduce_inconvenience_with_unite(a, b, roots=roots):
  root_a, n_a = find_root(a)
  root_b, n_b = find_root(b)
  if root_a == root_b:
    return 0
  else:
    if n_a > n_b:
      roots[root_a] = (root_a, n_a + n_b) # 二項目は何でも良い
      roots[root_b] = (root_a, n_a + n_b)
    else:
      roots[root_a] = (root_b, n_a + n_b) # 二項目は何でも良い
      roots[root_b] = (root_b, n_a + n_b)
    return n_a * n_b

for i, ab in enumerate(AB[:0:-1]): #実は1個めの橋は全く関係ない
  a, b = ab
  inconveniences[M-1-i] = inconveniences[M-i] - reduce_inconvenience_with_unite(a,b)

for inc in inconveniences[1:]:
  print(inc)