Harryxun/stf_run huggingface dataset:
import sys
import bisect
inputs = sys.stdin.readlines()

N, K = map(int, inputs[0].split())
X = list(map(int, inputs[1].split()))

if N == 1:
    print(abs(X[0]))
else:
    ans = 2 * 10 ** 8
    idx = bisect.bisect_left(X, 0)
    Y = X[max(0, idx-K):min(N, idx+K)]
    for i in range(N-K+1):
        y1, y2 = Y[i], Y[i+K-1]
        if y1 < 0 and y2 <= 0:
            ans = min(ans, -y1)
        elif y1 < 0 and 0 < y2:
            if -y1 < y2:
                ans = min(ans, -2*y1 + y2)
            else:
                ans = min(ans, -y1 + 2*y2)
        else:
            ans = min(ans, y2)
            break
    print(ans)

### FIXED CODE ###

import sys
inputs = sys.stdin.readlines()
 
N, K = map(int, inputs[0].split())
X = list(map(int, inputs[1].split()))
 
if N == 1:
    print(X[0])
else:
    ans = 10 ** 9
    for i in range(N-K+1):
        x1, x2 = X[i], X[i+K-1]
        if x1 <= 0 and x2 <= 0:
            ans = min(ans, -x1)
        elif x1 <= 0 and 0 < x2:
            if -x1 < x2:
                ans = min(ans, -2*x1 + x2)
            else:
                ans = min(ans, -x1 + 2*x2)
        else:
            ans = min(ans, x2)
            break
    print(ans)
N = int(input())
P = list(map(int, input().split()))
min = float('inf')
ans = 0
for i in range(N):
  if P[i] <= min(P[:(i+1)]):
    ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))
min = float('inf')
ans = 0
for i in range(N):
    if P[i] <= min:
        min = P[i]
        ans += 1
    # if P[i] <= min(P[:(i+1)]):
    #     ans += 1
print(ans)
import math
import numpy as np

L = int(input())
#print(L)

a0 = math.floor(L/2)
#print(a0)

cand = []

if a0==1:
  b0 = -2*a0 + L
  cand.append(a0*b0*a0)
else:
  for i in range(1,a0):
    b0 = -2*i + L
    cand.append(i*b0*i)

cand_np = np.array(cand)
print(cand_np.max())


### FIXED CODE ###

import math
import numpy as np

L = int(input())
a0 = L/3

print(a0*a0*a0)
n = int(input())
s = input()
if n % 2 == 1:
  print("No")

if s[0:s/2] == s[s/2:]:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

n = int(input())
s = input()
if n % 2 == 1:
  print("No")
else:
	if s[0:n//2] == s[n//2:]:
  		print("Yes")
	else:
  		print("No")
#!/usr/bin/env python
import math

def count_antidivision(n, x, y):
    """
    returns count of numbers from 1 to n which are not dividable by x nor y.
    """
    return n - n // x - n // y + n // (x * y // math.gcd(x, y))    

def main(A, B, C, D):
    return count_antidivision(B, C, D) - count_antidivision(A-1, C, D)

if __name__ == '__main__':
    A, B, C, D = list(map(int, input().split()))
    print(main(A, B, C, D))




### FIXED CODE ###

#!/usr/bin/env python
import fractions

def count_antidivision(n, x, y):
    """
    returns count of numbers from 1 to n which are not dividable by x nor y.
    """
    return n - n // x - n // y + n // (x * y // fractions.gcd(x, y))    

def main(A, B, C, D):
    return count_antidivision(B, C, D) - count_antidivision(A-1, C, D)

if __name__ == '__main__':
    A, B, C, D = list(map(int, input().split()))
    print(main(A, B, C, D))
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    A = il()
    t = [0]*N
    tmp = 1
    cnt = 0
    for n in range(N):
        if t[tmp-1] == 0:
            t[tmp-1] = A[tmp-1]
            tmp = A[tmp-1]
            cnt += 1
        else:
            break
    else:
        print(t[cnt-1])
        exit()

    mod = (K - cnt) % (len(t)-cnt)
    print(t[len(t)-cnt+1:][mod])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue
from decimal import Decimal

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    tel = [0] + il()

    # 初期位置
    position = 1

    # 移動回数がN回(町の数)以下の場合
    if K <= N:
        for k in range(K):
            position = tel[position]
        print(position)
        exit()

    # 移動回数がN回(町の数)以上の場合
    for n in range(N):
        position = tel[position]

    # 既にN回移動済みのため、
    # 必要な移動回数(K)から減算
    K -= N
    # ループまでに必要な移動回数を探索
    base = position
    cnt = 1
    while base != tel[position]:
        position = tel[position]
        cnt += 1

    # Kからループ数の余りを求め、
    # 余りの回数だけ移動を行う
    for k in range(K % cnt + 1):
        position = tel[position]
    print(position)


if __name__ == '__main__':
    main()
N = int(input())
List=list(map(int,input().split()))
List.sort()
a = List[0]
b = List.count(a)
c = List[N//3]
d = List.count(c)
e = List[2*N//3]
f = List.count(e)
if a == c and c == e:
    if a == 0 and b == N:
        print('Yes')
elif c == e:
    if a == 0  and N % 3 == 0 and b == N // 3 and d == 2 * N // 3:
        print('Yes')
elif N % 3 == 0 and b == N // 3 and d == N //3 and f == N //3 and a ^ e == c : 
    print('Yes')
else:
    print(A)


### FIXED CODE ###

N = int(input())
List=list(map(int,input().split()))
List.sort()
a = List[0]
b = List.count(a)
c = List[N//3]
d = List.count(c)
e = List[2*N//3]
f = List.count(e)
if a == c and c == e:
    if a == 0 and b == N:
        print('Yes')
    else:
        print('No')
elif c == e:
    if a == 0  and N % 3 == 0 and b == N // 3 and d == 2 * N // 3:
        print('Yes')
    else:
        print('No')
elif N % 3 == 0 and b == N // 3 and d == N //3 and f == N //3 and a ^ e == c : 
    print('Yes')
else:
    print('No')
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=[LI() for i in range(n)]
lis.sort()
s=[]
for i in range(n):
    for j in range(n):
        for k in range(n):
            for l in range(n):
                xl=min(lis[i][0],lis[j][0])
                xu=max(lis[i][0],lis[j][0])
                yl=min(lis[k][1],lis[l][1])
                yu=max(lis[k][1],lis[l][1])
                count=0
                for m in range(n):
                    if xl<=lis[m][0]<=xu and yl<=lis[m][1]<=yu:
                        count+=1
                if count>=k:
                    s.append((xu-xl)*(yu-yl))
print(max(s))
                    

    
            
        
        
    

    
        
    
    
    

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

a,b,c=MI()
if a==b:
    print(c)
elif b==c:
    print(a)
elif c==a:
    print(b)
x = int(input())
if x<100:
  print(0)
else:
  n = x//100
  m = x%100
  
  dp = set([1,2,3,4,5])
  
  for i in range(n):
    t = set([])
    for dp_i in dp:
      for j in range():
      	t.add((dp_i+j)%100)
    dp = t 
  
  if m in dp:
    print(1)
  else:
    print(0)


### FIXED CODE ###

x = int(input())

c = x//100

if c*100<=x and x<=c*105:
  print(1)
else:
  print(0)
import collections
import math

# 組み合わせ算出
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if __name__ == '__main__':
    N= int(input())
    a = list(map(int, input().split()))
    c = collections.Counter(a)
    result = 0
    for i in set(a):
        result += combinations_count(c[i], 2)

    for i in a:
        d = c[i]
        print(result -  combinations_count(d, 2) + combinations_count(d-1, 2))

### FIXED CODE ###

import collections
import math


if __name__ == '__main__':
    N= int(input())
    a = list(map(int, input().split()))
    c = collections.Counter(a)
    result = 0
    for i in set(a):
        # c[i]の中から2個選ぶ
        result += (c[i]*(c[i]-1))/2

    for i in a:
        d = c[i]
        print(int(result - (d*(d-1))/2 + ((d-1)*(d-2))/2))
N = int(input())
T, A = map(int, input().split())
s = [abs(A - (T - 0.006 * x)) for x in map(int, input().split())]
print(s.index(min(s) + 1))

### FIXED CODE ###

N = int(input())
T, A = map(int, input().split())
s = [abs(A - (T - 0.006 * x)) for x in map(int, input().split())]
print(s.index(min(s))+1)
inf = float('inf')
def main():
    n, k = map(int, raw_input().rstrip().split())
    h = list(map(int, raw_input().rstrip().split()))
    dp = [inf for i in range(n)]
    dp[0] = 0
    for i in range(n):
        for j in range(i+1, i+k+1):
            if j<n:
                cost = abs(h[i] - h[j])
                dp[j] = min(dp[j], dp[i] + cost)
    print(dp[n-1])

if __name__ == "__main__":
    main()


### FIXED CODE ###

inf = float('inf')
def main():
    n = int(input().rstrip())
    h = list(map(int, input().rstrip().split()))
    dp = [inf for i in range(n)]
    dp[0]=0
    for i in range(n):
        for j in [i+1, i+2]:
            if j<n:
                dp[j] = min(dp[j], dp[i]+ abs(h[i] - h[j]))
    print(dp[n-1])

if __name__ == "__main__":
    main()
import math
n,k = map(int,input().split())

if k == 1:
	print(0)
else:
	print(math.gcd(n,k))

### FIXED CODE ###

from fractions import gcd
n,k = map(int,input().split())

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

	for i in range(100000):
		a = min(a,abs(a-b))
	return a
if n == 0:
	print(0)
elif n ==1:
	if k == 1:
		print(0)
	else:
		print(1)
elif k == 1:
	print(0)
else:
	print(process(n,k))
a, b = map(int, input().split())

print(int(((a + b) / 2　+ 0.5)))



### FIXED CODE ###

a, b = map(int, input().split())

print(int((a + b) / 2 + 0.9))
import math
 
def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, k = map(int, input().split())
 
for i in range(1,k+1):
  ans = combinations_count(n-k+1, i)*combinations_count(k-1, i-1)
  ans = ans%(10**9+7)
  print(ans)
  

### FIXED CODE ###

import math
 
def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, k = map(int, input().split())

if n == k:
  for i in range(1, k+1):
    if i == 1:
      print(1)
    else:
      print(0)
else:
  for i in range(1,k+1):
    if i <= n-k+1:
      p1 = combinations_count(n-k+1, i)
      p2 = combinations_count(k-1, i-1)
      ans = p1*p2
      ans = ans%(10**9+7)
      print(ans)
    else:
      print(0)
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    s.append("o")
    a = s.count("o")-1
    print(700+a*100)
    return

#B
def B():
    _, x = LI()
    m = IR(n)
    m.sort()
    msum = sum(m)
    print(m + (x - msum) // m[0])
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    s.append("o")
    a = s.count("o")-1
    print(700+a*100)
    return

#B
def B():
    n, x = LI()
    m = IR(n)
    m.sort()
    msum = sum(m)
    print(n + (x - msum) // m[0])
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()
list1 = list(map(int, input().split()))
n = list1[0]
x = list1[1]
list2 = list(map(int, input().split()))
list2.append(x)
list2.sort()

list3 = []
length = len(list2)
index =1
while index < length:
    list3.append(list2[index]-list2[index-1])
    index+=1

list3.sort()
mimN = list3[0]
ans =0
index2 =mimN
if len(list3) ==1:
    print(mimN)
else:
    flag2 =0
    for number in list3:
       if number%mimN !=0:
           flag2 =1
    if flag2 ==0:
        print(mimN)
    else:
        while index2>=1:
            flag=1
            for number in list3:
                if number%index2 ==0:
                    flag =1
            if flag ==1:
                ans = index2
                break
            index2-=1
            
        print(ans)

### FIXED CODE ###

list = list(map(int, input().split()))
a = list[0]
b = list[1]

if a%2!=0 and b%2!=0:
    print("Yes")
else:
    print("No")
N = input()
test = list(map(int,input()))
M = input() 
  
for _ in range(M):
  a,b = int(input()).split()
  test[a] = b
  print(sum(test))

### FIXED CODE ###

N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  print(sum(test) - test[a-1] + b)
D, N = map(int, input().split())
l = []
for i in range(1, 100):
	if 100/i == D:
		l.append(i)
print(l[N-1])

### FIXED CODE ###

a,b=map(int,input().split())
if a<9 and b<9:
  print("Yay!")
else:
  print(":(")
import sys
input = sys.stdin.readline

a,b = ( int(x) for x in input().split() )

min_ = min([a,b])
max_ = max([a,b])

ret = a * b

for i in reversed(range(0,min_)):
  if max_ % i == 0 and min_ % i == 0:
    ret = min_ * max_ / i
    break

print(int(ret))

### FIXED CODE ###

import sys
input = sys.stdin.readline

a,b = ( int(x) for x in input().split() )

min_ = min([a,b])

ret = a * b

for i in reversed(range(1,min_+1)):
  if a % i == 0 and b % i == 0:
    ret = int(a * b / i)
    break

print(ret)
H, W = [int(item) for item in input().split()]
grid = [[item for item in input().strip()] for _ in range(H)]

# print(H, W) 
# print(grid)

dp = [[0 for _ in range(H+1)] for _ in range(W+1)]
dp[0][1] = 1

for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            pass
        else:
            dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j]

print(dp[H][W])

### FIXED CODE ###

H, W = [int(item) for item in input().split()]
grid = [[item for item in input()] for _ in range(H)]

dp = [[0 for _ in range(W+1)] for _ in range(H+1)]
max_num = 10**9 +7

def main():
    dp[0][1] = 1

    for i in range(H):
        for j in range(W):
            if grid[i][j] != '#':
                dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % max_num
            

    # print(dp)
    print(dp[H][W])

if __name__ == "__main__":
    main()
def multiple_factors(i, N):
  factors = []
  factors.append(int(1*i))
  for index in range(1, N//i):
    factors.append(int(index*i))
  return factors
  
def assign_ball(factors, blist, ai, b_add_index):
  sum_b = 0
  for index in range(len(factors)-1, 0, -1):
    sum_b += blist[factors[index]-1]
  
  if ai != sum_b%2:
    blist[factors[0]-1] =1
    b_add_index.append(str(factors[index]))
  return blist, b_add_index

      
N = int(input())
alist = list(map(int, input().split()))
blist = [0 for i in range(N)]
M = 0
b_add_index = []
for i in range(N-1,-1, -1):
  factors = multiple_factors(i+1, N)
  blist, b_add_index = assign_ball(factors, blist, alist[i], b_add_index)

if sum(blist)%2 != alist[0]:
  print(-1)
else:
  print(len(b_add_index))
  print(" ".join(b_add_index))

### FIXED CODE ###

print(3*(int(input())**2))
from intertools import product

D,G=map(int,input().split())
p,c=[],[]

for _ in range(D):
  pi,ci=map(int,input().split())
  p.append(pi)
  c.append(ci)
  
ans=10**4
  
for cpls in product((range(2),repeat=D)):
  num=0#回答数
  tensu=0#各cplsの得点
  for i,v in enumerate(cpls,start=1):
    if v==1:
      tensu+=i*100*p[i-1]+c[i-1]
      num+=p[i-1]
  if tensu>=G:
    ans=min(ans,num)
    continue
  for i,v in reversed(list(enumerate(cpls,start=1))):
    if v==0:
      for j in range(1,p[i-1]):
        tesu+=j*100*p[i-1]
        num+=1
        if tensu>=G:
          ans=min(ans,num)
          break
print(ans)
      
  
  


### FIXED CODE ###

from itertools import product

D,G=map(int,input().split())
p,c=[],[]

for _ in range(D):
  pi,ci=map(int,input().split())
  p.append(pi)
  c.append(ci)
  
ans=10**4
  
for cpls in product(range(2),repeat=D):
  num=0#回答数
  tensu=0#各cplsの得点
  for i,v in enumerate(cpls,start=1):
    if v==1:
      tensu+=i*100*p[i-1]+c[i-1]
      num+=p[i-1]
  if tensu>=G:
    ans=min(ans,num)
    continue
  for i,v in reversed(list(enumerate(cpls,start=1))):
    if v==0:
      for _ in range(p[i-1]-1):
        tensu+=100*i
        num+=1
        if tensu>=G:
          ans=min(ans,num)
          break
print(ans)
import sys, math, collections, heapq, itertools
  
def solve():
    file = sys.stdin.readline #single: int(file()), line: map(int, file().split())
    INF = 10 ** 25
    mod = 7 + 10 ** 9
    N = int(file())
    A = [int(a) for a in file().split()]
    A.sort()
    ans = 0
    out = []
    if N == 2:
        ans = A[1] - A[0]
        out = [A[1], A[0]]
    elif A[N-2] < 0:
        ans = A[N-1] - A[N-2]
        out.append([A[N-1], A[N-2]])
        for i in reversed(range(N-2)):
            out.append([ans, A[i]])
            ans -= A[i]
    elif A[1] >= 0:
        ans = A[0] - A[1]
        out.append([A[0], A[1]])
        for i in range(2, N-1):
            out.append([ans, A[i]])
        out.append([A[N-1], ans])
        ans = A[N-1] - ans
    else:
        for i in range(1, N-1):
            if A[i] >= 0:
                start = i-1
                break
        if -A[start] <= A[start + 1]:
            ans = A[0] - A[start + 1]
            out.append([A[0], A[start + 1]])
            for i in range(start + 2, N):
                out.append([ans, A[i]])
                ans -= A[i]
            out.append([A[start], ans])
            ans = A[start] - ans
            for i in range(1, start):
                out.append([ans, A[i]])
                ans -= A[i]
        else:
            ans = A[0] - A[start + 2]
            out.append([A[0], A[start + 2]])
            for i in range(start + 3, N):
                out.append([ans, A[i]])
                ans -= A[i]
            out.append([A[start + 1], ans])
            ans = A[start + 1] - ans
            for i in range(1, start + 1):
                out.append([ans, A[i]])
                ans -= A[i] 

    print(ans)
    for k in out:
        print(" ".join(map(str, k)))

    return 0
  
if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys, math, collections, heapq, itertools
from bisect import bisect_left
  
def solve():
    file = sys.stdin.readline #single: int(file()), line: map(int, file().split())
    INF = 10 ** 25
    mod = 7 + 10 ** 9
    N = int(file())
    A = [int(a) for a in file().split()]
    A.sort()
    ans = 0
    out = []
    if N == 2:
        ans = A[1] - A[0]
        out = [[A[1], A[0]]]
    else:
        plus = bisect_left(A, 0)
        if plus == 0:
            ans = A[0]
            for i in range(1, N-1):
                out.append([ans, A[i]])
                ans -= A[i]
            out.append([A[N-1], ans])
            ans = A[N-1] - ans
        elif plus < N:
            ans = A[0]
            for i in range(plus, N - 1):
                out.append([ans, A[i]])
                ans -= A[i]
            out.append([A[N-1], ans])
            ans = A[N-1] - ans
            for i in range(1, plus):
                out.append([ans, A[i]])
                ans -= A[i]
        else:
            ans = A[N-1]
            for i in range(N-1):
                out.append([ans, A[i]])
                ans -= A[i]

    print(ans)
    for k in out:
        print(" ".join(map(str, k)))


    return 0
  
if __name__ == "__main__":
    solve()
N = int(input())
S = [input().sort() for _ in range(N)]

from scipy.misc import comb

def main():
    dic = {}
    ans = 0
    for s in S:
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
    for val in dic.values():
        if val > 1:
            ans += comb(val,2)
    print(ans)
    return

if __name__ == "__main__":
    main()


### FIXED CODE ###

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

Dic = [1]*N
prime = {"a":2,"b": 3, "c":5, "d":7,"e": 11,"f": 13,"g": 17,"h": 19,"i": 23,"j": 29,"k": 31,"l": 37,"m": 41, "n":43,"o": 47,"p": 53,"q": 59,"r": 61,"s": 67,"t": 71,"u": 73,"v": 79,"w": 83,"x": 89,"y": 97,"z":101}

from operator import mul
from functools import reduce

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


for i in range(N):
    for s in S[i]:
        Dic[i]*= prime[s]

Dic.sort()
pre = Dic[0]
ans = 0
temp = 1
for d in Dic[1:]:
    if pre == d:
        temp += 1
    else:
        if temp >= 2:
            ans += comb(temp,2)
        pre = d
        temp = 1

ans += comb(temp,2) if temp >= 2 else 0
print(int(ans))