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

from collections import defaultdict
A = defaultdict(int)
B = defaultdict(int)
C = defaultdict(int)

N = int(input())
a = [k for k in map(int, input().split())]
b = [k for k in map(int, input().split())]
c = [k for k in map(int, input().split())]

for k in range(N):
  A[a[k]] += 1
  B[b[k]] += 1
  C[c[k]] += 1

Aset = sorted(set(a))
Bset = sorted(set(b))
Cset = sorted(set(c))

cnt = 0
index_a = 0
index_c = 0
a = 0
c = N

for b in Bset:
  flag_a = False
  flag_c = False
  for k in range(index_a, len(Aset)):
    if Aset[k] < b:
      a += A[Aset[k]] 
    else:
      index_a = k
      flag_a = True
      break
  for k in range(index_c, len(Cset)):
    if Cset[k] <= b:
      c -= C[Cset[k]]
    else:
      index_c = k
      flag_c = True
      break
  if flag_a == False:
    a = N
  if flag_c == False:
    c = 0
  cnt += a*c*B[b]
print(cnt)

### FIXED CODE ###

from collections import defaultdict
A = defaultdict(int)
B = defaultdict(int)
C = defaultdict(int)

N = int(input())
a = [k for k in map(int, input().split())]
b = [k for k in map(int, input().split())]
c = [k for k in map(int, input().split())]

for k in range(N):
  A[a[k]] += 1
  B[b[k]] += 1
  C[c[k]] += 1

Aset = sorted(set(a))
Bset = sorted(set(b))
Cset = sorted(set(c))

cnt = 0
index_a = 0
index_c = 0
a = 0
c = N

for b in Bset:
  flag_a = False
  flag_c = False
  if a < N:
    for k in range(index_a, len(Aset)):
      if Aset[k] < b:
        a += A[Aset[k]] 
      else:
        index_a = k
        flag_a = True
        break
  for k in range(index_c, len(Cset)):
    if Cset[k] <= b:
      c -= C[Cset[k]]
    else:
      index_c = k
      flag_c = True
      break
  if flag_a == False:
    a = N
  if flag_c == False:
    break
  cnt += a*c*B[b]
print(cnt)
### BUGGY CODE ###

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

if N < M:
    cost = []
    for i in range(M-1):
        cost.append(abs(X[i] - X[i+1]))
    for i in range(N-1):
        cost.remove(max(cost))
    
    print(sum(cost))
else:
    print(0)

### FIXED CODE ###

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

L = [X[i+1] - X[i] for i in range(M-1)]
L = sorted(L, reverse=True)

del L[:N-1]
print(sum(L))
### BUGGY CODE ###

N, K, Q = input().split()
A = []
for i in range(int(Q)):
  A.append(int(input()))

if int(K) > int(Q):
  for i in range(int(N)):
    print("Yes")
else:
  goods = list(set([i for i in A if A.count(i) >= int(Q) - int(K) + 1]))
  for i in range(1,int(N)+1):
    if i in goods:
      print("Yes")
    else:
      print("No")

### FIXED CODE ###

import numpy as np
_N, _K, _Q = input().split()
N, K, Q = int(_N), int(_K), int(_Q)
A = []
for i in range(Q):
  A.append(int(input()))

if K > Q:
  for i in range(N):
    print("Yes")
else:
  score = K * np.ones(N) - Q
  for i in A:
    score[i-1] += 1
  for i in score:
    if i > 0:
      print("Yes")
    else:
      print("No")
### BUGGY CODE ###

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

ev = [(a+1)/2 for a in A]
ans = 0
for i in range(len(A)-K+1):
  ans = max(ans, sum(ev[i:i+K]))
print(ans)  

### FIXED CODE ###

import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
A = np.array(readline().split(), dtype=np.int64)
A = np.array([(1+a)/2 for a in A])

Acum = np.zeros(N+1, np.float64)
Acum[1:] = A.cumsum()

x = Acum[K:] - Acum[:-K]
print(x.max())
### BUGGY CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
Q = int(input())
prime = set()
for i in range(1,100000,2):
    if len(make_divisors(i)) == 2:
        if len(make_divisors((i+1)//2)) == 2:
            prime.add(i)
for i in range(Q):
    l,r = (int(x) for x in input().split())
    lr = set([i for i in range(l,r+1,2)])
    print(len(prime & lr))

### FIXED CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
Q = int(input())
prime = set()
cuml = []
count = 0
for i in range(1,100000,2):
    if len(make_divisors(i)) == 2:
        if len(make_divisors((i+1)//2)) == 2:
            prime.add(i)
for i in range(1,100000,2):
    if i in prime:
        count += 1
    cuml.append(count)
for i in range(Q):
    l,r = (int(x) for x in input().split())
    if l > 1:
        print(cuml[(r-1)//2]-cuml[(l-3)//2])
    else:
        print(cuml[(r-1)//2])
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
used = [False] * n
ans = 0

def judge(x):
    while x % 2 == 0:
        x //= 2
    return x == 1

for i in range(n):
    if used[i]:
        continue
    else:
        for j in range(i+1, n):
            if used[j]:
                continue
            if judge(a[i] + a[j]):
                used[i] = True
                used[j] = True
                ans += 1
                break

print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
cnt = Counter(a)
ans = 0

def make(x):
    num = 1
    while num <= x:
        num *= 2
    return num

for i in range(n):
    x = make(a[i])
    if cnt[x - a[i]] > 0 and cnt[a[i]] > 0 and x != 2 * a[i]:
        ans += 1
        cnt[x - a[i]] -= 1
        cnt[a[i]] -= 1
    elif x == 2 * a[i] and cnt[a[i]] > 1:
        ans += 1
        cnt[a[i]] -= 2

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

import math

n = int(input())
s = input()
S = [ord(i) - 97 for i in s]
q = int(input())
H = math.ceil(math.log(n) / math.log(2))
LH = 1 << H

def build_tree_for_letter(letter):
    tree = [False for _ in range(2<<H)]
    for i in range(1<<H):
        tree[i + (1<<H)] = True if i < n and s[i] == chr(97 + letter) else False

    for i in range(H-1, -1, -1):
        for x in range(1<<i, 2<<i):
            tree[x] = any((tree[x<<1], tree[(x<<1)+1]))

    return tree


def build():
    trees = []
    for letter in range(26):
        trees.append(build_tree_for_letter(letter))

    return trees


def update(x, letter, positive=True):
    x += (1<<H)
    trees[letter][x] = (positive == True)
    while x > 1:
        x >>= 1
        trees[letter][x] = any((trees[letter][x << 1], trees[letter][(x << 1) + 1]))


def query(ll, rr):

    # print("query: ", l, r)
    total = 0
    for letter in range(26):
        l, r = ll + (1<<H), rr + (1<<H)
        is_letter = False
        while l < r:
            if l%(2) != 0:
                is_letter = any((is_letter, trees[letter][l]))
                l += 1
            l //= 2
            if r%(2) != 0:
                is_letter = any((is_letter, trees[letter][r-1]))
                r -= 1
            r //= 2
        total += is_letter
    return total



trees = build()

for i in range(q):
    a, b, c = input().split()
    b = int(b) - 1
    if int(a) == 1:
        c = ord(c) - 97
        update(b, S[b], positive=False)
        S[b] = c
        update(b, c, positive=True)
    else:
        c = int(c)
        print(query(b, c))








### FIXED CODE ###

import math

n = int(input())
s = input()
S = [ord(i) - 97 for i in s]
q = int(input())
HEIGHT = math.ceil(math.log(n) / math.log(2))
SIZE = 1 << HEIGHT

def build_tree():
    tree = [0 for _ in range(SIZE<<1)]

    for i, letter in enumerate(s):
        tree[i+SIZE] = 1<<(ord(letter)-97)

    for i in range(HEIGHT - 1, -1, -1):
        for x in range(1<<i, 2<<i):
            tree[x] = tree[x<<1] | tree[(x<<1)+1]

    return tree




def update(x, number):
    tree[x] = number
    while x > 1:
        x >>= 1
        tree[x] = tree[x << 1] | tree[(x << 1) + 1]


def query(l, r):
    total = 0
    while l < r:
        if l&1:
            total |= tree[l]
            l += 1
        l >>= 1
        if r&1:
            r -= 1
            total |= tree[r]
        r >>= 1
    return bin(total).count('1')



tree = build_tree()

for i in range(q):
    a, b, c = input().split()
    b = int(b) - 1
    if int(a) == 1:
        update(b + SIZE, S[b])
        c = 1 << (ord(c) - 97)
        S[b] = c
        update(b + SIZE, c)
    else:
        print(query(b + SIZE, int(c)+SIZE))
### BUGGY CODE ###

from numpy.linalg import matrix_power
from numpy import mat

class mint:
    def __init__(self, i, mod=10 ** 9 + 7):
        self.mod = mod
        self.i = i % mod
    def __add__(self, other):
        return mint(self.i + other.i)
    def __mul__(self, other):
        return mint(self.i * other.i)
    def __str__(self):
        return str(self.i)

N, K = map(int, input().split())
A = mat([[mint(int(i)) for i in input().split()] for _ in range(N)])

print(matrix_power(A, K).sum())

### FIXED CODE ###

from numpy import array, eye

mod = 10 ** 9 + 7

N, K, *A = map(int, open(0).read().split())
A = array(A, dtype=object).reshape(N, N)

ans = eye(N, dtype=object)
while K:
    if K & 1:
        ans = (ans.dot(A)) % mod
    A = A.dot(A) % mod
    K //= 2

print(ans.sum() % mod)
### BUGGY CODE ###

s=input()
K=int(input())
D=[]
for i in range(len(s)+1):
  for j in range(len(s)-i):
    D.append(s[i:i+j+1])
D = sorted(list(set(D)))
#print(D)
print(D[K-1])

### FIXED CODE ###

s=input()
K=int(input())
D=[]
for i in range(len(s)+1):
  for j in range(min(len(s)-i,5)):
    D.append(s[i:i+j+1])
D = sorted(list(set(D)))
#print(D)
print(D[K-1])
### BUGGY CODE ###

e = list(map(int,input().split()))
a = e[0]
b = e[1]
c = e[2]
d = e[3]

def div(x,y):
    cnt = 0
    for i in range(a,b+1):
        if (int(i/x)-i/x != 0) and (int(i/y)-i/y != 0):
            cnt += 1
    return cnt

print(div(c,d))

### FIXED CODE ###

e = list(map(int,input().split()))
a,b,c,d = e

def gcd(x,y):
    while y !=0:
        x,y = y,x%y
    return x

def sums(x):
    S1 = x//c
    S2 = x//d
    S3 = x// (c*d//gcd(c,d))
    return x - S1 - S2 + S3


print(sums(b)-sums(a-1))
### BUGGY CODE ###

n, m = map(int, input().split())
list_open = []
for i in range(m):
  list_open.append(list((int(i) for i in input().split())))
dict_open = {}
for i in range(m):
  for j in range(list_open[i][0], list_open[i][1] + 1):
    try:
      dict_open[j] += 1
    except:
      dict_open[j] = 1
print(list(dict_open.values()).count(m))

### FIXED CODE ###

n, m = map(int, input().split())
min_num = 0
max_num = 10**5
           
for i in range(m):
  min_temp, max_temp = map(int, input().split())
  if min_temp > min_num:
    min_num = min_temp
  if max_temp < max_num:
    max_num = max_temp
print(max(max_num - min_num + 1, 0))
### BUGGY CODE ###

S = input()
N = len(S)
c = [1 for _ in range(N)]

dic = {}
freq = 0
start = 0
for i in range(N):
  tmp = [0 for _ in range(N)]
  for j in range(N):
    if j > 0 and S[j - 1] == "R":
      tmp[j] += c[j - 1]
    if j < N - 1 and S[j + 1] == "L":
      tmp[j] += c[j + 1]
  c = tmp
  if str(c) in dic.keys():
    freq = i - dic[str(c)]
    start = dic[str(c)]
    break
  else:
    dic[str(c)] = i

n = start + ((10 ** 100 - start - 1) % freq)
key = [k for k, v in dic.items() if v == n][0]
key = key.replace("[", "").replace("]", "")
k = list(key.split(", "))
for i in range(N):
  print(k[i], end = "")
  if i == N - 1:
    print()
  else:
    print(" ", end = "")

### FIXED CODE ###

S = input()
N = len(S)

ans = []
RL = []
s = "R"
flag = False
for i in range(1, N):
  if S[i] == "L" or S[i] == "R" and S[i - 1] == "R":
    s += S[i]
  else:
    RL.append(s)
    s = "R"
RL.append(s)

for rl in RL:
  for i in range(len(rl)):
    if rl[i] == "R" and rl[i + 1] == "L" or rl[i] == "L" and rl[i - 1] == "R":
      if i % 2 == 1:
        ans.append(len(rl) // 2)
      else:
        ans.append((len(rl) + 1) // 2)
    else:
      ans.append(0)

for i in range(N):
  print(ans[i], end = "")
  if i == N - 1:
    print()
  else:
    print(" ", end = "")
### BUGGY CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    n,m = LI()
    e = collections.defaultdict(set)
    for _ in range(m):
        a,b = LI()
        e[a-1].add(b-1)
        e[b-1].add(a-1)
    r = [0] * n

    qq = I()
    for _ in range(qq):
        v,d,c = LI()
        v -= 1
        r[v] = c
        f = [False] * n
        f[v] = True
        q = [v]
        for __ in range(d):
            t = []
            for p in q:
                for vv in e[p]:
                    if f[vv]:
                        continue
                    f[vv] = True
                    t.append(vv)
                    r[vv] = c
            q = t

    return '\n'.join(map(str, r))



print(main())


### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    n,m = LI()
    e = collections.defaultdict(set)
    for _ in range(m):
        a,b = LI()
        e[a-1].add(b-1)
        e[b-1].add(a-1)
    r = [0] * n

    q = I()
    qq = sorted([[_] + LI() for _ in range(q)], reverse=True)
    f = [-1] * n
    for _,v,d,c in qq:
        v -= 1
        if f[v] >= d:
            continue
        if r[v] == 0:
            r[v] = c
        q = [v]
        for nd in range(d-1,-1,-1):
            t = []
            for p in q:
                for vv in e[p]:
                    if f[vv] >= nd:
                        continue
                    f[vv] = nd
                    t.append(vv)
                    if r[vv] == 0:
                        r[vv] = c
            q = t

    return '\n'.join(map(str, r))



print(main())
### BUGGY CODE ###

n,m=(int(i) for i in input().split(' '))
i=m//n
if m==2147483647:
  print(1)
  exit()
while True:
  if i==1:
    print(i)
    break
  if m%i==0 and m//i>=n:
    print(i)
    break
  else:
    i-=1


### FIXED CODE ###

import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
for i in range(1,n):
  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):
    print('1')
    exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break
### BUGGY CODE ###

#-------------
A,B,C = map(int, input().split())
K = int(input())
#-------------

while True :
  if A >= B :
    B = B*2
    K -= 1
  if B >= C :
    C = C*2
    K -= 1
  if K == 0 :
    break

if A<B<C :
  print("Yes")
else:
  print("No")

### FIXED CODE ###

#-------------
A,B,C = map(int, input().split())
K = int(input())
#-------------
card = []
for i in range(K):
  B_x = B*(2**i)
  C_x = C*(2**(K-i))
  card.append([A,B_x,C_x])

cnt = 0
for i in range(len(card)):
  if card[i][2] > card[i][1] > card[i][0] :
    cnt +=1

if cnt >= 1:
  print("Yes")
else:
  print("No")
### BUGGY CODE ###

n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]

length = 0
for i in range(n) :
    for j in range(n):
        route = 10000000000
        for k in range(n):
            if k == i or k == j : continue
            route = min(route, a[i][k] + a[k][j] ) #< a[i][j]
            if route < a[i][j]:
                print(-1)
                exit() 
        if route > a[i][j] :
            length +=  a[i][j]
print(int(length/2))

### FIXED CODE ###

n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]

length = 0
for i in range(n) :
    for j in range(n):
        route = 10000000000
        for k in range(n):
            if k == i or k == j : continue
            route = min(route, a[i][k] + a[k][j] ) #< a[i][j]
            if route < a[i][j]:
                print(-1)
                exit() 
        if route > a[i][j] :
            length +=  a[i][j]
print(int(length/2))
### BUGGY CODE ###

import numpy as np
n, x, y = map(int, input().split())

ans = np.zeros(n+1,dtype=np.int64)
for i in range(1,n):
    for j in range(i+1,n+1):
        ans[min(j-i,abs(x-i)+1+abs(y-j))] += 1

for i in range(1,n):
    print(ans[i])

### FIXED CODE ###

import numpy as np
n, x, y = map(int, input().split())

ans = [0] * n
for i in range(1,n):
    for j in range(i+1,n+1):
        ans[min(j-i,abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(x-j))] += 1

for i in range(1,n):
    print(ans[i])
### BUGGY CODE ###

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

mod = 10**9 + 7
ans = 0

for d in range(60):
    n0, n1 = 0, 0
    for i in range(N):
        if (A[i] >> d) & 1:
            n1 += 1
        else:
            n0 += 1
    ans = (ans + (n0 * n1) * pow(2,d,mod))% mod
    
print(ans)

### FIXED CODE ###

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

mod = 10**9 + 7
ans = 0

for d in range(60):
    n0, n1 = 0, 0
    for i in range(N):
        if (A[i] >> d) & 1:
            n1 += 1
        else:
            n0 += 1
    ans = (ans + (n0 * n1) * (1 << d))% mod
    
print(ans)
### BUGGY CODE ###

N=int(input())
ans=[0]*N
for x in range(1,int((N-1)/2)):
    for y in range(x,int((N-1)/2)):
        for z in range(y,int((N-1)/2)):
            if x**2+y**2+z**2+x*y+y*z+z*x<=N:
                if x==y and y==z:
                    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=1
                elif x==y or y==z or z==x:
                    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=3
                else:
                    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=6
for n in range(N):
    print(ans[n])

### FIXED CODE ###

N=int(input())
ans=[0]*N
for x in range(1,int((N-1)/2)):
    for y in range(x,int((N-1)/2)):
        if x ** 2 + y ** 2 + 1 ** 2 + x * y + y * 1 + 1 * x > N:
            break
        for z in range(y,int((N-1)/2)):
            if x**2+y**2+z**2+x*y+y*z+z*x<=N:
                if x==y and y==z:
                    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=1
                elif x==y or y==z or z==x:
                    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=3
                else:
                    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=6
            else:
                break

for n in range(N):
    print(ans[n])
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
    b.append(a[i])
    b = [b[i] for i in reversed(range(len(b)))]

for i in range(n):
    print(b[i],'', end = '')
print()


### FIXED CODE ###

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

if n % 2 == 0:
    for i in range(n):
        if i < int(n / 2):
            print(a[n - 2 * i - 1],'', end = '')
        else:
            print(a[2 * i - n],'', end = '')
else:
    for i in range(n):
        if i <= n // 2:
            print(a[n - 2 * i - 1],'', end = '')
        else:
            print(a[2 * i - n],'', end = '')
print()
### BUGGY CODE ###

import time
time.sleep(19)

### FIXED CODE ###

print(int(input())**3)
### BUGGY CODE ###

N = int(input())
A = []
for i in range(N):
	A.append(int(input()))
A.sort()
ary1 = [A[0]]
ary2 = [A[N-1]]
fst = 0
lst = N
fst_flg = False
sum1, sum2 = 0,0
while fst + 1 < lst:
	if fst_flg:
		fst_flg = False
		if fst + 2 != lst:
			fst += 1
			ary1 = [A[fst]] + ary1 + [A[fst+1]]
			ary2 = [A[N-1-fst]] + ary2 + [A[N-1-fst-1]]
			fst += 1
			l = len(ary1)
			sum1 += abs(ary1[0]-ary1[1]) + abs(ary1[l-1]-ary1[l-2])
			sum2 += abs(ary2[0]-ary2[1]) + abs(ary2[l-1]-ary2[l-2])
		else:
			fst += 1
			ary1 = [A[fst]] + ary1
			ary2 = [A[N-1-fst]] + ary2
			sum1 += abs(ary1[0]-ary1[1])
			sum2 += abs(ary2[0]-ary2[1])
	else:
		fst_flg = True
		if fst + 2 != lst:
			lst -= 1
			ary1 = [A[lst]] + ary1 + [A[lst-1]]
			ary2 = [A[N-1-lst]] + ary2 + [A[N-lst]]
			lst -= 1
			l = len(ary1)
			sum1 += abs(ary1[0]-ary1[1]) + abs(ary1[l-1]-ary1[l-2])
			sum2 += abs(ary2[0]-ary2[1]) + abs(ary2[l-1]-ary2[l-2])
		else:
			lst -= 1
			ary1 = [A[lst]] + ary1
			ary2 = [A[N-1-lst]] + ary2
			sum1 += abs(ary1[0]-ary1[1])
			sum2 += abs(ary2[0]-ary2[1])
print(max(sum1,sum2))

### FIXED CODE ###

N = int(input())
A = []
for i in range(N):
	A.append(int(input()))
A.sort()
if N % 2 == 0:
	print(-2*sum(A[:N//2-1]) + 2*(sum(A[N//2+1:])) + A[N//2] - A[N//2-1])
	exit()

a = 2*sum(A[N//2+1:]) - 2*sum(A[:N//2-1]) - A[N//2] - A[N//2-1]
b = 2*sum(A[N//2+2:]) - 2*sum(A[:N//2]) + A[N//2] + A[N//2+1]
print(max(a,b))
### BUGGY CODE ###

N = int(input())
list_S = []
for i in range(N):
  a = str(input())
  if not a in list_S: list_S.append(a)
print(len(list_S))

### FIXED CODE ###

N = int(input())
list_S = [str(input()) for i in range(N)]
print(len(list(set(list_S))))
### BUGGY CODE ###

n = int(input())
li = [input() for a in range(n)]
li2 = []
for w in li:
  di = {}
  for x in w:
    if x in di:
      di[x] += 1
    else:
      di[x] = 1
  li2.append(di)
  
li3 = []
for l in li2:
  wl = ''
  for k in sorted(l):
    wl += k + str(l[k])
  li3.append(wl)

ans = 0
for n, wx in enumerate(li3):
  for wy in li3[n+1:]:
    if wx == wy:
      ans += 1

print(ans)

### FIXED CODE ###

n = int(input())
li = [''.join(sorted(input())) for _ in range(n)]

ans = 0
w_dic = {}
for l in li:
  if not w_dic.get(l):
    w_dic[l] = 1
  else:
    ans += w_dic[l]
    w_dic[l] = w_dic[l] + 1

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

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

def yakusu(x):
    tmp=int(pow(x, 1/2))+1
    out=set()
    for i in range(1, tmp):
        if x%i==0:
            out.add(i)
            out.add(x//i)
    if pow(x, 1/2)%1==0:
        out.add(pow(x, 1/2))
    out=list(out)
    out.sort()
    return out
  
counter=0

B=[0]*(10**6+1)
for a in A:
  B[a]+=1

A=set(A)
for a in A:
  nums=yakusu(a)
  nums=nums[:-1]
  judge=True
  for num in nums:
    if num in A:
      judge=False
      
  if judge==True and B[a]==1:
    counter+=1

print(counter)

### FIXED CODE ###

N=int(input())
A=list(map(int, input().split()))
A.sort()
B=[1]*(10**6+1)
counter=0

if N==1:
  print(1)
  exit()
  
if N==2:
  if A[0]==A[1]:
    print(0)
  elif A[1]%A[0]==0:
    print(1)
  else:
    print(2)
  exit()
  
for i in range(N):
  if 0<i<N-1 and (A[i]==A[i-1] or A[i]==A[i+1]):
    if B[A[i]]!=0:
      B[A[i]]=0
      j=2
      while A[i]*j<=10**6:
        B[A[i]*j]=0
        j+=1
    continue
  elif i==0 and A[i]==A[i+1]:
    if B[A[i]]!=0:
      B[A[i]]=0
      j=2
      while A[i]*j<=10**6:
        B[A[i]*j]=0
        j+=1
    continue
  elif i==N-1 and A[i-1]==A[i]:
    if B[A[i]]!=0:
      B[A[i]]=0
      j=2
      while A[i]*j<=10**6:
        B[A[i]*j]=0
        j+=1
    continue
  
  if B[A[i]]==1:
    counter+=1
    j=2
    while A[i]*j<=10**6:
      B[A[i]*j]=0
      j+=1
print(counter)