Harryxun/stf_run huggingface dataset:
n = int(input())
v = list(sorted(map(int, input().split())))

counts = {}
x = v[0]
c = 0
for i in v:
    if i != x:
        counts[x] = c
        x = i
        c = 0
    c += 1
counts[x] = c

v1 = list(counts)

sums = [0]
for i in range(1, 1001):
    try:
        sums.append(v1.index(i))
    except ValueError:
        sums.append(sums[-1])


total = 0
for i, x in enumerate(v[:n-2]):
    if x == 1:
        continue
    for j, y in enumerate(v[i+1:n-1]):
        total += (sums[min(1000, x+y-1)] - sums[y])



for i, c in counts.items():
    if c >= 2:
        total += (sums[min(1000, 2*i-1)] - sums[c])





# v3
total += sum(True if c >= 3 else False for c in counts.values())


print(total)

### FIXED CODE ###

n = int(input())
v = list(sorted(map(int, input().split())))
v.append(2000)
total = n*(n-1)*(n-2) / 6



def bs(left, s):
    right = n+1
    while left < right-1:
        m = (right+left)//2

        if v[m]>=s:
            right = m
        else:
            left = m
    return left+1






for i, x in enumerate(v[:-2]):
    for j, y in enumerate(v[i+1:-1]):
        k = bs(j+1, y+x)
        total -= (n-k)

print(int(total))
N = int(input())

point = []
dist = []

for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    dist.append(abs(x) + abs(y))

distSort = sorted(dist)
maxDist = dist[-1]
for d in distSort :
    if (maxDist - d) % 2 == 1 :  # 実現不可能
        print(-1)
        break
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for i, (x, y) in enumerate(point) :
        out = ['']
        if x < 0 :
            out = ['L'] * abs(x)
        elif x > 0 :
            out = ['R'] * abs(x)
        print(''.join(out), end='')

        out = ['']
        if y < 0 :
            out = ['D'] * abs(y)
        elif y > 0 :
            out = ['U'] * abs(y)
        print(''.join(out), end = '')

        out = ['']
        R = (maxDist - dist[i]) // 2
        if R > 0 :
            out = ['LR'] * R
        print(''.join(out))



### FIXED CODE ###

N=int(input())

point = []
parity = {}
for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    parity[(x + y) % 2] = 1

if len(set(parity)) == 2 :
    print('-1')
else :
    m = 38
    parity = 1 if (1 in parity) else 0
    print(m + 1 - parity)
    if parity == 1 :  # 距離が奇数
        print(*[1 << i for i in range(m)])
    else :
        print(1, *[1 << i for i in range(m)])

    def arm(x, y, m) :
        if abs(x) >= abs(y) :
            if x >= 0 :
                return ('R', x - (1<<m), y)
            else :
                return ('L', x + (1<<m), y)
        else :
            if y >= 0 :
                return ('U', x, y - (1<<m))
            else :
                return ('D', x, y + (1<<m))

    for x, y in point :
        ans = []
        for i in range(m-1, -1, -1) :
            mode, x, y = arm(x, y, i)
            ans.append(mode)
        if parity == 0 :  # 偶数の場合一つ足す
            if x == 1 :
                ans.append('R')
            elif x == -1 :
                ans.append('L')
            elif y == 1 :
                ans.append('U')
            elif y == -1 :
                ans.append('D')
        print(''.join(ans[::-1]))
#create environment
import numpy as pd
num = 1
i = 1
k = 1
df = pd.DataFrame()
count_num = 0
f = lambda x: (x**2)

#input1 N D (numeric)
N, D = map(int, input().split())
#input2
for l in range(0, N):
  a = map(int, input().split())
  if a is none:
    break
  df[l] = a

# make combination
df_new = df.T
#a_new = a.T
print(df_new)
for i in range(0, len(df_new.index)):
  for j in range(k, len(df_new.index)):
#    print_str = str(i) + '-' + str(j)
#    print(print_str)
    k = k + 1
    df_new_ij = df_new.loc[[i,j],:]
    obj_num = np.sqrt(df_new_ij.apply(f).cumsum().iloc[1,:].cumsum()[len(df['a'])-1])
    
    if obj_num == round(obj_num):
      count_num = count_num + 1

#print
print(count_num)






### FIXED CODE ###

import math
n, d = map(int, input().split())
x = []
ans=0
for i in range(n):
        o = list(map(int, input().split()))
        x += [o]
for i in range(n):
        for j in range(i+1,n):
                dis_net = 0
                dis=0
                for u in range(d):
                        dis += (x[i][u] - x[j][u])** 2
                dis_net = math.sqrt(dis)
                if dis_net % 1 == 0 and dis_net>=1:
                        ans += 1
print(ans)
N = int(input())
# white: 0, black: 1
g = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    g[u-1].append((v-1, w))
    g[v-1].append((u-1, w))

visited = [False]*N
def dfs(num, kyori): # 始点からの距離
    if not visited[num]:
        visited[num] = '1' if kyori%2 == 1 else '0'
        for hen in g[num]:
            dfs(hen[0], kyori+hen[1])
    return visited

print('\n'.join(dfs(0,0)))

### FIXED CODE ###

N = int(input())
# white: 0, black: 1
g = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    g[u-1].append((v-1, w))
    g[v-1].append((u-1, w))

visited = [False]*N
from collections import deque

q = deque()
q.append([0, 0])
while q:
    num, kyori = q.pop()
    visited[num] = '1' if kyori%2 == 1 else '0'
    for hen in g[num]:
        if not visited[hen[0]]:
            q.append([hen[0], kyori+hen[1]]) 

print('\n'.join(visited))
A,B,K=list(map(int,input().split()))
count=0
z=[A,B]
for i in range(max(z),0,-1):
  if (A%i==0)and(B%i==0):
    count+=1
    if count==K:
      ans=i
      break
print(ans)

### FIXED CODE ###

a=list(map(int,input().split()))
A=a[0]
B=a[1]
C=a[2]
if B>=A*C:
  answer=C
else:
  answer=B//A
print(answer)
from collections import Counter

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

_sum = 0
for key,value in cnts.items():
    _sum +=  value*(value-1)//2

for ai in a:
    ans = _sum
    c = cnts.count(ai)
    ans -= c*(c-1)//2
    ans += (c-1)*(c-2)//2
    print(ans)


### FIXED CODE ###

from collections import Counter

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

_sum = 0
for key,value in cnts.items():
    _sum +=  value*(value-1)//2

for ai in a:
    ans = _sum
    c = cnts[ai]
    ans -= c*(c-1)//2
    ans += (c-1)*(c-2)//2
    print(ans)
N = int(input())
A = list(map(int,input().split()))

f = [i for i in range(N)]
left, right = 0, 0
nowxor = A[0]
nowsum = A[0]
while True:
    if right+1 < N:
        if nowxor ^ A[right+1] == nowsum + A[right+1]:
            nowxor = nowxor ^ A[right+1]
            nowsum = nowsum + A[right+1]
            right += 1
        else:
            if left == right:
                nowxor = A[left+1]
                nowsum = A[left+1]
                left, right = left+1, right+1
            else:
                nowxor = nowxor ^ A[left]
                nowsum = nowsum - A[left]
                left += 1
    else:
        nowxor = nowxor ^ A[left]
        nowsum = nowsum - A[left]
        left += 1
    f[left] = right
    if left == N-1 and right == N-1:
        break
ans = 0
for i in range(N):
    ans += f[i]-i+1
print(ans)

### FIXED CODE ###

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

f = [i for i in range(N)]
left, right = 0, 0
ans = 0
nowxor = 0
nowsum = 0
for left in range(N):
    while right < N and nowxor ^ A[right] == nowsum + A[right]:
        nowsum += A[right]
        nowxor = nowxor ^ A[right]
        right += 1
    ans += right - left
    if left == right:
        right += 1
    else:
        nowsum -= A[left]
        nowxor = nowxor ^ A[left]
print(ans)
n=int(input())
lst=list(map(int,input().split()))
premin=lst[0]
ans=0
for x in lst:
  if min_list>=x:
    ans+=1
    premin=x
print(ans)


### FIXED CODE ###

n=int(input())
lst=list(map(int,input().split()))
premin=lst[0]
ans=0
for x in lst:
  if premin>=x:
    ans+=1
    premin=x
print(ans)
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 
MOD = 10**9+7
INF = 1<<60

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

def resolve():
    N, M = map(int, inp().split())
    G = np.zeros((N + 1, N + 1))

    for _ in range(M):
        x, y = map(int, inp().split())
        G[x, y] += 1
        G[y, x] += 1
    csr = csr_matrix(G)
    dist, pred = dijkstra(csgraph=csr, indices=1, return_predecessors=True)

    ans = pred[2:]
    impos = any(ans >= 0)
    if impos:
        print("Yes")
        print(*ans, sep="\n")
    else:
        print("No")

if __name__ == "__main__":
    resolve()

### FIXED CODE ###


from collections import deque
def resolve():
    N, M = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(M):
        x, y = map(lambda x:int(x)-1, input().split())
        G[x].append(y)
        G[y].append(x)

    dist = [-1]*N
    ans = [0]*N
    q = deque()
    q.append(0)
    while q:
        fm = q.popleft()
        for to in G[fm]:
            if dist[to] != -1:
                continue
            dist[to] += 1
            ans[to] = fm
            q.append(to)

    print("Yes")
    for i in range(1, N):
        print(ans[i] + 1)
        
if __name__ == "__main__":
    resolve()
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            t, n = map(int, raw_input().split())
            if t == n == 0:
                break
            obs = []
            for i in range(n):
                x, y = map(int, raw_input().split())
                obs.append((x, y))
            sx, sy = map(int, raw_input().split())
            q = [(sx, sy, 0)]
            visited = set([(sx, sy)])
            d = [(1, 0), (1, 1), (0, 1), (-1, 0), (-1, -1), (0, -1)]
            while q:
                x, y, turn = q.pop(0)
                if turn >= t:
                    break
                for dx, dy in d:
                    if not (x + dx, y + dy) in obs:
                        visited.add((x + dx, y + dy))
                        q.append((x + dx, y + dy, turn + 1))
            # print visited
            print len(visited)
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

### FIXED CODE ###

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

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            t, n = map(int, raw_input().split())
            if t == n == 0:
                break
            obs = []
            for i in range(n):
                x, y = map(int, raw_input().split())
                obs.append((x, y))
            sx, sy = map(int, raw_input().split())
            q = [(sx, sy, 0)]
            visited = set([(sx, sy)])
            d = [(1, 0), (1, 1), (0, 1), (-1, 0), (-1, -1), (0, -1)]
            while q:
                x, y, turn = q.pop(0)
                if turn >= t:
                    break
                for dx, dy in d:
                    if not (x + dx, y + dy) in obs and not (x + dx, y + dy) in visited:
                        visited.add((x + dx, y + dy))
                        q.append((x + dx, y + dy, turn + 1))
            # print visited
            print len(visited)
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()
n=int(input())

for i in range(n):
    if i % 3 == 0 or i//10 == 3 :
        print(str(i) + " ")
    else : 



### FIXED CODE ###

n=int(input())
for i in range(n):
    if (i+1) % 3 == 0 or "3" in str(i+1) :
        print(" " + str(i+1), end="")
print()
import sys
inp = sys.stdin.readline
out = print
MAX = 10**9

n, k = map(int, inp().split())
cost = list(map(int, inp().split()))
dp = [MAX] * (n)
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(h[i] - h[j]) for j in range(max(0, i - K), i))

out(dp[-1])


### FIXED CODE ###

#!/usr/bin/env pypy

import sys
inp = sys.stdin.readline
out = print
MAX = 10**9
 
n, k = map(int, inp().split())
cost = list(map(int, inp().split()))
dp = [MAX] * (n)
dp[0] = 0
 
for i in range(1, n):
    dp[i] = min(dp[j] + abs(cost[i] - cost[j]) for j in range(max(0, i - k), i))
 
out(dp[-1])
import sys

sys.setrecursionlimit(20000)

def dfs(temp):
    global dist, e, count_from, count_to
    global count, parent

    if temp < 0:
        return 0

    if count[temp] == count_from[temp]:
        for to in e[temp]:
            count[to] += 1
            temp_dist = dist[temp] + 1
            if temp_dist > dist[to]:
                parent[to] = temp
                dist[to] = temp_dist
            dfs(to)

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

count_from = [0] * N
count_to = [0] * N
e = [[] for _ in range(N)]

for i in range(N + M - 1):
    a, b = map(int, input().split())
    e[a - 1].append(b - 1)
    count_from[b - 1] += 1
    count_to[a - 1] += 1

start = 0
for i in range(N):
    if count_from[i] == 0:
        start = i
        break

dist = [0] * N
count = [0] * N
parent = [-1] * N

dfs(start)

for i in range(N):
    print(parent[i] + 1)

### FIXED CODE ###

import sys

sys.setrecursionlimit(100001)

def dfs(temp):
    global dist, e, count_from, count, parent

    if count[temp] == count_from[temp]:
        for to in e[temp]:
            count[to] += 1
            temp_dist = dist[temp] + 1
            if temp_dist > dist[to]:
                parent[to] = temp
                dist[to] = temp_dist
            dfs(to)

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

count_from = [0] * N
count_to = [0] * N
e = [[] for _ in range(N)]

for i in range(N + M - 1):
    a, b = map(int, input().split())
    e[a - 1].append(b - 1)
    count_from[b - 1] += 1
    count_to[a - 1] += 1

start = 0
for i in range(N):
    if count_from[i] == 0:
        start = i
        break

dist = [0] * N
count = [0] * N
parent = [-1] * N

dfs(start)

for i in range(N):
    print(parent[i] + 1)
a,b,c=map(int.input().split())
l=sorted([a,b,c])
print(l[2]*10 + l[1] + l[0])

### FIXED CODE ###

a,b,c=map(int,input().split())
l=sorted([a,b,c])
print(l[2]*10 + l[1] + l[0])
a, b = map(float, input().split())
print(math.floor(a*b))



### FIXED CODE ###

from decimal import Decimal
a, b = map(Decimal, input().split())
#print(a*b)
c = a*b
c = int(c)
print(c)
N, K = map(int,input().split())
A = list(map(int,input().split()))
B = [0]
S = set([]);S.add(0)
now = 0
Flag = False
loop_start = -1
if K <= 2*pow(10,5)+10:
  for i in range(K):
    nxt = A[now]-1
    B.append(nxt)
    now = nxt
  print(B)
  print(B[K]+1)
  exit()
for i in range(K):
  nxt = A[now]-1
  #print(now,nxt)
  if nxt in S:
    if Flag:
      if nxt == loop_start:
        #print(nxt,i)
        loop_cycle = i-loop_num
        break
    else:
      loop_start = nxt
      loop_num = i
      Flag = True
  else:
    B.append(nxt);S.add(nxt)
  now = nxt
#print(B,loop_start,loop_cycle,loop_num)
loc = (K-loop_start)%loop_cycle+loop_start
#print(loc)
print(B[loc]+1)

### FIXED CODE ###

N , K = map(int,input().split())
 
A = list(map(int,input().split()))
 
reach = [-1 for i in range(N)]
reach[0] = 0 #最初の町は0回でいく
now = 0
#loop = 1
dic ={}
dic[0] = 0
for i in range(N):
  to = A[now]-1
  if reach[to] != -1:
    ini = i+1
    #print(i,to,reach[to])
    loop = i+1 - reach[to]
    break
  if i+1 not in dic:
    dic[i+1] = to
  reach[to] = i+1
  #loop += 1
  now = to
 
 
#print(dic,reach,loop,ini)
if K < ini:
  print(dic[K]+1)
else:
  t = (ini-loop) + (K-ini)%loop
  print(dic[t]+1)
N=int(input())
A=list(map(int,input().split()))
a=[]
B=[]
ans=0
for i in range(1,N):
    b=A[i]+A[0]
    a.append(b-i)
    B.append(A[i]-A[0])
ans=a.counter(0)
for i in range(N):
    b=B[i]
    a1=a[i:].copy()
    a1=a1-[b-i-1]
    ans+=a1.counter(0)
print(ans)

### FIXED CODE ###

import bisect
N=int(input())
A=list(map(int,input().split()))
L=[]
R=[]
ans=0
for i in range(N):
    L.append(i+1+A[i])
    R.append(i+1-A[i])
L.sort()
R.sort()
for i in L:
    l=bisect.bisect_left(R,i)
    r=bisect.bisect_right(R,i)
    ans=ans+r-l
print(ans)
N, K = map(int, input().split())
S = input()
new_S = []
count_S = []

cur_c = S[0]
cur_count = 0

new_S.append(cur_c)
for c in S:
    if c == cur_c:
        cur_count += 1
    else:
        new_S.append(c)
        count_S.append(cur_count)
        cur_count = 1
        cur_c = c
count_S.append(cur_count)        

new_count = []
st_ix = 0
if S[0] == '0':
    cur_sum = sum(count_S[:2*K])
    st_ix = 1
    new_count.append(cur_sum)
else:
    cur_sum = sum(count_S[:2*K+1])
    new_count.append(cur_sum)

en_ix = st_ix + 2*K + 1
cur_sum = sum(count_S[st_ix:en_ix])
new_count.append(cur_sum)

while en_ix < len(count_S):
    # shift st_ix
    st_ix = st_ix + 2
    en_ix = en_ix + 2
    cur_sum -= (count_S[st_ix-2] + count_S[st_ix-1])
    cur_sum += (count_S[max(en_ix-2, len(count_S)-1]
                        + count_S[max(en_ix-1, len(count_S)-1])
    new_count.append(cur_sum)

print(max(new_count))


### FIXED CODE ###

N, K = map(int, input().split())
S = input()
new_S = []
count_S = []

cur_c = S[0]
cur_count = 0

new_S.append(cur_c)
for c in S:
    if c == cur_c:
        cur_count += 1
    else:
        new_S.append(c)
        count_S.append(cur_count)
        cur_count = 1
        cur_c = c
count_S.append(cur_count)        

new_count = []
st_ix = 0
if S[0] == '0':
    cur_sum = sum(count_S[:2*K])
    st_ix = 1
    new_count.append(cur_sum)
else:
    cur_sum = sum(count_S[:2*K+1])
    new_count.append(cur_sum)

en_ix = st_ix + 2*K + 1
cur_sum = sum(count_S[st_ix:en_ix])
new_count.append(cur_sum)

while en_ix < len(count_S):
    # shift st_ix
    st_ix = st_ix + 2
    en_ix = en_ix + 2
    if en_ix >= len(count_S):
        new_count.append(sum(count_S[st_ix:]))
    else:
        cur_sum -= (count_S[st_ix-2] + count_S[st_ix-1])
        cur_sum += (count_S[en_ix-2]
                        + count_S[en_ix-1])
    new_count.append(cur_sum)

print(max(new_count))
n = int(input())
a_l = list(map(int, input().split()))
if min(a_l) !=1:
    print(-1)
else:
    i = 1
    a_l = a_l[a_l.index(i)+1:]
    i += 1
    while True:
        if a_l.count(i) > 0:
            a_l = a_l[a_l.index(i)+1:]
            i += 1
        else:
            break
print(n - (i-1))

### FIXED CODE ###

n = int(input())
a_l = list(map(int, input().split()))
if min(a_l) !=1:
    print(-1)
    exit()
else:
    ans = 1
    for i in a_l:
        if i == ans:
            ans += 1
print(n-ans+1)
import sys
input = sys.stdin.readline
 
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
n,q = list(map(int,input().split()))
ball = list(map(int,input().split()))
 
h = Bit(n+1)

L_most = {}
J = [[] for _ in range(max(ball)+1)]
jump = {}
on = set()

for i,b in enumerate(ball):
  if b not in L_most:
    L_most[b]=i
    h.add(i+1,1)
    on.add(i+1)
  J[b].append(i)
    
for i in range(n+1):
  for j in range(len(J[i])):
    if j+1<len(J[i]):
      jump[J[i][j]+1] = J[i][j+1]+1

Q = []
 
for _ in range(q):
  l,r = list(map(int,input().split()))
  Q.append((l,r))
  
LOO = list(Q)
Q.sort(key=lambda x:x[0])

c = 1
ans = {}
#print(on)

for l,r in Q:
  for i in range(c,l):
    if i in on:
      on.remove(i)
      h.add(i,-1)
      if i in jump:
        dest = jump[i]
        h.add(dest,1)
        on.add(dest)

  tmp = h.sum(r)- h.sum(l-1)
  ans[(l,r)] = tmp
  c = l

for q in LOO:
  print(ans[q])
  
  
  

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
n,q = list(map(int,input().split()))
ball = list(map(int,input().split()))
 
h = Bit(n+1)

L = {}
jump = {}
on = set()

for i,b in enumerate(ball):
  if b not in L:
    h.add(i+1,1)
    on.add(i+1)
  if b in L:
    jump[L[b]]=i+1
  L[b] = i+1

Q = []
 
for _ in range(q):
  l,r = list(map(int,input().split()))
  Q.append((l,r))
  
LOO = list(Q)
Q.sort(key=lambda x:x[0])

c = 1
ans = {}

for l,r in Q:
  for i in range(c,l):
    if i in on:
      on.remove(i)
      h.add(i,-1)
      if i in jump:
        dest = jump[i]
        h.add(dest,1)
        on.add(dest)

  tmp = h.sum(r)- h.sum(l-1)
  ans[(l,r)] = tmp
  c = l

p = []
for q in LOO:
  p.append(ans[q])
  
print(*p, sep="\n")
from decimal import*
n = int(input())
a = input().split(" ")
kotae=Decimal(1)
lista = [int(n) for n in a]
for i in range(n):
  kotae*=Decimal(lista[i])
if kotae>10**18:
  kotae=-1
print(int(kotae))
  

### FIXED CODE ###

n = int(input())
a = input().split(" ")
kotae=1
listaa = [int(n) for n in a]
lista = sorted(listaa)
if lista[0]==0:
  print(0)
  exit()
for i in range(n):
  kotae*=lista[i]
  if kotae>10**18:
    kotae=-1
    break
if kotae>10**18:
  kotae=-1
print(kotae)
n = int(input())
a = list(map(int,input().split()))
dic_S = {0:[0]}
S = 0
ans = 0
for i in range(n):
    S += a[i]
    if S not in dic_S:
        dic_S[S] = []
    else:
        pass
    dic_S[S].append(a[i])
    

for k in dic_S.keys():
    I = len(dic_S[k])
    if 3 <= I:
        ans += (I*(I-1))// *2
    elif I == 2:
        ans += 1
    else:
        pass
print(ans)


### FIXED CODE ###

import math
n = int(input())
a = list(map(int,input().split()))
dic_S = {0:[0]}
S = 0
ans = 0
for i in range(n):
    S += a[i]
    if S not in dic_S:
        dic_S[S] = []
    else:
        pass
    dic_S[S].append(a[i])
    

for k in dic_S.keys():
    I = len(dic_S[k])
    if 3 <= I:
        ans += math.factorial(I) // (math.factorial(I-2)*2)
    elif I == 2:
        ans += 1
    else:
        pass
print(ans)
a,b,c,d=map(iint,input().split())
print(a*b if a*b>c*d else c*d)

### FIXED CODE ###

a,b,c,d=map(int,input().split())
print(a*b if a*b>c*d else c*d)
n = int(input())
print(Christmas + " Eve" * (25-n))

### FIXED CODE ###

n = int(input())
print("Christmas" + " Eve" * (25-n))
n=int(input())
arr = map(int,input().split())
k=0
if n%2==1:
	k1=0
	k2=0
	for i in range(n//2):
		k1=k1+arr[i]-arr[n-i-1]
	print(abs(abs(k1)-arr[n//2]))
else:
	for i in range(n//2):
		k=k+arr[i]-arr[n-1-i]
	print(abs(k))

### FIXED CODE ###

N=input()
b=input().split()
sum=0
bigsum=0
for i in b:
    sum+=eval(i)
standard=sum/2
for i in b:
    bigsum+=eval(i)
    if bigsum>standard:
        smallsum=bigsum-eval(i)
        break
if bigsum-standard>standard-smallsum:
    print(sum-2*smallsum)
else:
    print(2*bigsum-sum)
n = int(input())
s = []
for i in range(n):
    s.append(input())
    
dic = dict()
ans = 0
for i in s:
    if "".join(sorted(i)) in dic:
        ans += dic[i]
        dic[i] +=1
    else:
        dic[i] = 1
print(ans)

### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(input())
    
dic = dict()
ans = 0
for i in s:
    if "".join(sorted(i)) in dic:
        ans += dic["".join(sorted(i))]
        dic["".join(sorted(i))] +=1
    else:
        dic["".join(sorted(i))] = 1
print(ans)