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

flag = 0
even = []
odd = []
for i in a:
    if i%2 == 0:
        even.append(i)
    else:
        odd.append(i) 

if n%2 == 1:
    if len(odd) >= 1:
        flag = 1
    else:
        for i in range(n):
            count = 0
            for j in range(i, n):
                aa = a[i]^a[j]
                if aa in a:
                    count += 1
                if count < 2:
                    flag = 1
                    break
            else:
                continue
            break

else:
    if len(odd)/2 != len(even):
        flag = 1
        for i in range(n):
            count = 0
            for j in range(i, n):
                aa = a[i]^a[j]
            if aa in a:
                count += 1
            if count < 2:
                flag = 1
                break
        else:
            continue
        break

if flag == 1:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

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

t = 0
for a_i in a:
    t ^= a_i
    # print(t)
print("Yes" if t==0 else "No")
a = int(input())
b = []
n = 1
for i in range(a):
  b.append(int(input()))
  
for i in range(a):
  n = n * b[i]

if n > 10**18:
  print('-1')
else:
  print(n)

### FIXED CODE ###

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

c = 0
d = 0

for i in b:
    if i == 0:
        c += 1
    elif i > 10**18:
        d += 1
        
if c > 0:
    print(0)
    exit()
if d > 1 and c == 0:
    print(-1)
    exit()

for i in b:
  n *= i
  if n > 10**18:
    print(-1)
    exit()
print(n)
N,K = map(int,input().split())
A = list(map(int,input().split()))
r = [0]*N
p = 0
q = 1 #現在地
for i in range(K):
    q = A[q-1] #次の町
    if r[q-1] == 0:
        p += 1
        r[q-1] += p       
    else:
        p += 1
        y = r[q-1]
        break
z = (K-y) % (p-y)
for i in range(N):
    if r[i] == y+z:
        print(i+1)

### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
r = [0]*N
p = 0
q = 1 #現在地
for i in range(K):
    if i == K-1:
        print(A[q-1])
        exit()
    q = A[q-1] #次の町
    if r[q-1] == 0:
        p += 1
        r[q-1] += p       
    else:
        p += 1
        y = r[q-1]
        break
z = (K-y) % (p-y)
for i in range(N):
    if r[i] == y+z:
        print(i+1)
n, x = [int(i) for i in input().split()]

3 <= n <= 100

if n == x == 0:
    break

for a in range(n+1):
    for b in range(a+1):
        for c in range(b+1):
             if a == b == c or a == b or a == c or b == c:
             None
             if a + b + c == x:
             return
             else:
             None
print()

### FIXED CODE ###

while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n+1):
        for m in range(s+1, n):
            for e in range(m+1, n+1):
                if x == sum([s, m, e]):
                    count += 1

    print(count)
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

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

N = int(input())
T = [int(input()) for i in range(N)]
ans = 1
for i in range(len(T)):
    ans = lcm(ans, T[i])

print(int(ans))

### FIXED CODE ###

import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(list):
    return reduce(lcm_base, list, 1)

N = int(input())
T = [int(input()) for i in range(N)]

print(lcm_list(T))
# c = list(map(int, input().split()))
# a, b, c = map(int, input().split())
# a = [list(map(int, list(input()))) for i in range(n)]
n, a, b = map(int, input().split())

r = (n / (a + b))
m = n % (a + b)

if (m <= a):
    v = m
elif m >= a and m <= b:
    v = a

print(int(r * a + v))


### FIXED CODE ###

# c = list(map(int, input().split()))
# a, b, c = map(int, input().split())
# a = [list(map(int, list(input()))) for i in range(n)]
n, a, b = map(int, input().split())

m = n % (a + b)

if (m <= a):
    v = m
else:
    v = a

print(int(n / (a + b)) * a + v)
from collections import Counter


def read():
    N, M, Q = map(int, input().split())
    ABCD = []
    for i in range(Q):
        a, b, c, d = map(int, input().split())
        ABCD.append((a, b, c, d))
    return N, M, Q, ABCD


def check(N, M, Q, ABCD, x):
    score = 0
    for a, b, c, d in ABCD:
        if x[b-1] - x[a-1] == c:
            score += d
    return score



def solve(N, M, Q, ABCD):
    smax = 0
    for a in range(M+1):
        for b in range(a, M+1):
            for c in range(b, M+1):
                for d in range(c, M+1):
                    for e in range(d, M+1):
                        for f in range(e, M+1):
                            for g in range(f, M+1):
                                for h in range(g, M+1):
                                    for i in range(h, M+1):
                                        for j in range(i, M+1):
                                            s = check(N, M, Q, ABCD, [a, b, c, d, e, f, g, h, i, j][:M])
                                            smax = max(s, smax)
    return smax


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("{}".format(outputs))


### FIXED CODE ###

from collections import Counter
import sys
sys.setrecursionlimit(200000)


def read():
    N, M, Q = map(int, input().split())
    ABCD = []
    for i in range(Q):
        a, b, c, d = map(int, input().split())
        ABCD.append((a, b, c, d))
    return N, M, Q, ABCD


def check(N, M, Q, ABCD, x):
    score = 0
    for a, b, c, d in ABCD:
        if x[b-1] - x[a-1] == c:
            score += d
    return score


def solve(N, M, Q, ABCD):
    smax = 0
    for a in range(1, M+1):
        for b in range(a, M+1):
            for c in range(b, M+1):
                for d in range(c, M+1):
                    for e in range(d, M+1):
                        for f in range(e, M+1):
                            for g in range(f, M+1):
                                for h in range(g, M+1):
                                    for i in range(h, M+1):
                                        for j in range(i, M+1):
                                            s = check(N, M, Q, ABCD, [a, b, c, d, e, f, g, h, i, j][:N])
                                            smax = max(s, smax)
    return smax


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("{}".format(outputs))
def main():
    n = int(input())
    words = {}
    for _ in range(n):
        a = input()
        if a in words:
            words[a] += 1
        else:
            words[a] = 1

    max_val = max(words.values())
    # words_sorted = sorted(words.items(), key=lambda x: x[0])
    for key, value in sorted(words):
        if value != max_val:
            continue
        else:
            print(key)
            # key valueを両方printするとき
            # print('{}:{}'.format(key, value))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    words = {}
    for _ in range(n):
        a = input()
        if a in words:
            words[a] += 1
        else:
            words[a] = 1
    max_val = 0
    results = []
    for i in words.keys():
        if words[i] > max_val:
            max_val = words[i]
            results = []
            results.append(i)
        elif words[i] == max_val:
            results.append(i)

            # results = [key
            #            for key in words.keys() if words[key] == max(words.values())]
            # results.sort()
    results.sort()
    print('\n'.join(map(str, results)))


if __name__ == "__main__":
    main()
n = int(input())
l = [{}, {}, {}, {2, 5, 63}, {2, 5, 20, 63}, {2, 3, 4, 6, 9}]
if n <= 5:
  print(*l[n])
l = [2, 3, 4, 6]
s = set()
for i in range(n):
  s.add(l[i%4] + 6*(i//4))
if sum(s) % 6 == 2:
  s.remove(8)
  s.add(30000)
if sum(s) % 6 == 3:
  s.remove(9)
  s.add(30000)
if sum(s) % 6 == 5:
  s.remove(9)
  s.add(29998)
print(*s)

### FIXED CODE ###

n = int(input())
l = [{}, {}, {}, {2, 5, 63}, {2, 5, 20, 63}, {2, 3, 4, 6, 9}]
if n <= 5:
  print(*l[n])
  exit(0)
l = [2, 3, 4, 6]
s = set()
for i in range(n):
  s.add(l[i%4] + 6*(i//4))
if sum(s) % 6 == 2:
  s.remove(8)
  s.add(30000)
if sum(s) % 6 == 3:
  s.remove(9)
  s.add(30000)
if sum(s) % 6 == 5:
  s.remove(9)
  s.add(29998)
print(*s)
N = int(input())
for k in range(N+2):
    if k * (k-1) == 2 * N:
        S = [[] for _ in range(k+1)]
        n = 1
        for i in range(2, N+1):
            for j in range(1, i):
                S[i].append(n)
                S[j].append(n)
                n += 1
        print(k)
        for i in range(1, k+1):
            ans = [len(S[i])] + S[i]
            print(' '.join(map(str, ans)))
        exit()
print('No')

### FIXED CODE ###

N = int(input())
for k in range(N+2):
    if k * (k-1) == 2 * N:
        S = [[] for _ in range(k+1)]
        n = 1
        for i in range(2, k+1):
            for j in range(1, i):
                S[i].append(n)
                S[j].append(n)
                n += 1
        print('Yes')
        print(k)
        for i in range(1, k+1):
            ans = [len(S[i])] + S[i]
            print(' '.join(map(str, ans)))
        exit()
print('No')
K = input()
A,B = input().split()5

k = int(K)
a = int(A)
b = int(B)

x = a // k
z = b // k

for i in range(z-x + 1):
  if a <= k*i and k*i <= b:
    print("OK")
    exit()

### FIXED CODE ###

K = input()
A,B = input().split()

k = int(K)
a = int(A)
b = int(B)

x = a // k
z = b // k

# print(x,z)
for i in range(z-x + 1):
#   print("fof---", k*(x+i))
  if a <= k*(x+i) and k*(x+i) <= b:
        print("OK")
        exit()
print("NG")
# Setup
import sys
sys.setrecursionlimit(4100000)

a, b = [int(i) for i in input().split()]
c = [b-int(i) for i in input().split()]
import fractions
import fractions
temp = fractions.gcd(c[1],c[0])
for i in range(2,a):
    temp = fractions.gcd(temp,c[i])
print(temp)

### FIXED CODE ###

# Setup
import sys
sys.setrecursionlimit(4100000)

a, b = [int(i) for i in input().split()]
c = [b-int(i) for i in input().split()]
import fractions
if a >= 2:
  temp = fractions.gcd(c[1],c[0])
  for i in range(2,a):
      temp = fractions.gcd(temp,c[i])
  print(abs(temp))
else:
  print(abs(c[0]))
n, k = [int(c) for c in input().split()]
hs = [int(c) for c in input().split()]
dp = [0] * n
for i in range(1, n):
  dp[i] = 0
  pre = min(i, k)
  while pre > 0:
   	dp[i] = min(dp[i], dp[i-pre] + abs(hs[i-pre] - hs[i]))
    pre -= 1
print(dp[-1])


### FIXED CODE ###

n, k = map(int, input().split())
hs = list(map(int, input().split()))
dp = [float('inf')] * n
dp[0] = 0
for i in range(1, n):
  pre = min(i, k)
  while pre > 0:
    dp[i] = min(dp[i], dp[i-pre] + abs(hs[i-pre] - hs[i]))
    pre -= 1
print(dp[-1])
from string import *
h,w=map(int,input().split())

s =[None] * h
for i in range(h):
    s[i] = [None] * w
    for j in range(w):
        s[i][j] = input()

for i in range(h):
    for j in range(w):
        if(s[i][j]=='snuke'):
            idx1=ascii_lowercase[i].swapcase()
            idx2=str(j+1)
            print(idx1+idx2)
            break

### FIXED CODE ###

from string import *
h,w=map(int,input().split())

s = [input().split() for _ in range(h)]

for i in range(h):
    for j in range(w):
        if(s[i][j]=='snuke'):
            idx1=ascii_lowercase[j].swapcase()
            idx2=str(i+1)
            print(idx1+idx2)
            exit()
n=int(input())
x=1000000000000000000
res=1
for i in range(n):
  x=int(input())
  res=res*x
if(res>x):
  print("-1")
else:
  print(res)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
res=1
if 0 in a:
  print("0")
else:
  for x in a:
    res=res*x
    if(res>1000000000000000000):
      res=-1
      break
  print(res)
a,b = map(int, input())
if a * b % 2 == 0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a,b = map(int, input().split())
if (a * b) % 2 == 0:
  print("Even")
else:
  print("Odd")
a,b = map(int, input().split())
c = a*b
if c % 2 = 0
    print("Even")
else
    print("Odd")

### FIXED CODE ###

a, b = map(int, input().split())
c = a*b
if c % 2:
    print("Odd")
else:
    print("Even")
import math
r,g,b,n  = (int(i) for i in input().split())
z =  math.factorial(r) * math.factorial(b) * math.factorial(g)
a =  math.factorial(n) // z
print( a)

### FIXED CODE ###

n, k = (int(i) for i in input().split()) 
a =  n - k + 1
print( a)
N = int(input())
chars = "Xabcdefghijklmnopqrstuvwxyz"  # x番目がほしいときにchars[x-1]としたくないので、chars[0]は使わないことにします

n_rem = n  # 入力を直接操作すると、もし後々必要になったときに面倒なので
res = ""
while True:
  x = N % 26
  if x == 0:
    x = 26
  res += chars[x]
  n_rem -= x
  
  if n_rem == 0:
    break
  n_rem //= 26
print(res[::-1])

### FIXED CODE ###

n = int(input())
chars = "Xabcdefghijklmnopqrstuvwxyz"  # x番目がほしいときにchars[x-1]としたくないので、chars[0]は使わないことにします

n_rem = n  # 入力を直接操作すると、もし後々必要になったときに面倒なので
res = ""
while True:
  x = n_rem % 26
  if x == 0:
    x = 26
  res += chars[x]
  n_rem -= x
  
  if n_rem == 0:
    break
  n_rem //= 26
print(res[::-1])
s=int(input())
print(int(s*3.14)

### FIXED CODE ###

s=int(input())
print(2*s*3.14)
line = input().split()
a = line[0]
b = line[1]

if a > 8 or b > 8:
    print(':(')
else:
    print('Yay!')

### FIXED CODE ###

line = input().split(' ')
a = line[0]
b = line[1]

if int(a) > 8 or int(b) > 8:
    print(':(')
else:
    print('Yay!')
N=int(input())
S=input()
ans=0
cnt=0
for i in range(N):
  if S[i]='I':
    cnt+=1
    ans=max(cnt,ans)
  else:
    cnt-=1
print(ans)

### FIXED CODE ###

N=int(input())
S=input()
ans=0
cnt=0
for i in range(N):
  if S[i]=='I':
    cnt+=1
    ans=max(cnt,ans)
  else:
    cnt-=1
print(ans)
a,b=map(int,input().split())
 for i in range(a):
  for j in range(b):
   if i+j=a and i*2+4*j=b:
    print("Yes")
     break
   else:
     print("No")
  

### FIXED CODE ###

a,b=map(int,input().split())
ans=1
for i in range(0,b):
  for j in range(0,b):
   if i+j==a and i*2+4*j==b:
    ans+=1
    break
   else:
     pass

if ans>1:
  print("Yes")
else:
  print("No")
from functools import reduce
l = [int(input()) for _ in range(5)]
r = [i % 10 for i in l if i % 10 != 0]
l = [i // 10 * 10 + 10 for i in l]
print(reduce(lambda a, b: a + b, l) + min(r if r else 0) - 10)

### FIXED CODE ###

import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
l = [a, b, c, d, e]
ans = 9
n = 0
j = 0
for i in [i % 10 for i in l]:
    if i != 0 and i < ans:
        ans = i
        n = j
    j += 1
m = l.pop(n)
r = 0
for i in l:
    r += math.ceil(i / 10) * 10
print(r + m)
n,k = map(int,input().split())
a = list(map(int,input().split()))
l = [1]

for i in range(1,k+1):
  ind = l[-1]
  if a[ind-1] in set(l):
    l.append(a[ind-1])
    roop = l[-1]
    nokori = k-i
    break
    
  else:
    l.append(a[ind-1])
    
l.pop()
rooplist = l[l.index(roop):]
rooplen = len(rooplist)
mod = nokori%rooplen

print(rooplist[mod])

### FIXED CODE ###

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

d = {}
for i in range(1, n + 1):
    d[i] = a[i - 1]

did = set()
route = [1]

now = 1
for i in range(k):
    now = d[now]
    route.append(now)
    if now in did:
        break
    did.add(now)

if k < 10 ** 6:
    now = 1
    for i in range(k):
        now = d[now]

    print(now)

else:
    for i in range(len(route)):
        if route[i] == route[-1]:
            roop = route[i:-1]
            print(roop[(k - i) % len(roop)])
            exit()
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if K <= N:
	answer = N * X
elif K > N:
	answer = (K * X) + (N - K) * Y:
print(answer)    

### FIXED CODE ###

N = int(input())
K = int(input())
X = int(input())
Y = int(input())
 
if N <= K :
	answer = X * N
elif N >= K + 1:
	answer = (X * K) + (Y * (N - K) )
print(answer)
N = int(input())

XYHA = []

for i in range(N):
    XYHA.append(input().split(" "))

HC = 0
CX = 0
CY = 0
OKFLG = True

for i in range(101):
    for j in range(101):
        HC = 0
        OKFLG = True
        for k in range(N+1):
            XYH = XYHA[k]
            H = int(XYH[2]) + abs(int(XYH[0]) - i) + abs(int(XYH[1]) - j)
            if HC == 0:
                HC = H
                CX = i
                CY = j
                continue
            
            if HC == H:
                continue
            else:
                OKFLG = False
                break

        if OKFLG:
            break
    if OKFLG:
        break


print(CX,CY,HC)

### FIXED CODE ###

N = int(input())
 
info = []
 
for i in range(N):
    x,y,h = map(int,input().split())
    if h == 0:
        N -= 1
        continue
    info.append([x,y,h])
 
for i in range(101):
    for j in range(101):
        H_0 = info[0][2] + abs(info[0][0] - i) + abs(info[0][1] - j)
        
        for k in range(1, N):
            H = info[k][2] + abs(info[k][0] - i) + abs(info[k][1] - j)
            
            if H_0 != H:
                break
            elif k == N - 1:
                print(i,j,H_0)
                exit()
 
print(info[0][0],info[0][1],info[0][2])
m=10**9+7
i=s=r=0
f=1
*a=open(0).read().split()
for x in a[1:]:i+=1;s+=pow(i,m-2,m);r+=int(x)*~-s+int(a[-i])*s;f=f*i%m
print(r*f%m)

### FIXED CODE ###

m=10**9+7
i=s=r=0
f=1
_,*a=open(0).read().split()
for x in a:i+=1;s+=pow(i,m-2,m);r+=int(x)*~-s+int(a[-i])*s;f=f*i%m
print(r*f%m)
def pathSmMax(matrix,i,j,cache):
    if i > len(matrix)-1: return 0
    happiness = 0
    if cache[i][j] != 0:
        return cache[i][j]
    for k in range(3):
        if k != j:
            cache[i][j] = max(cache[i][j],pathSmMax(matrix,i+1,k,cache) + matrix[i][j])
    return cache[i][j]
N = int(input())
matrix = []
for i in range(N):
    matrix.append([int(i) for i in input().split()])
maxs = -float("inf")
cache = [[0 for i in range(4)] for j in range(len(matrix)+1)]
for i in range(len(matrix)):
    maxs = max(maxs,pathSmMax(matrix,0,i,cache))
print(maxs)

### FIXED CODE ###

N = int(input())
matrix = []
for i in range(N):
    matrix.append([int(i) for i in input().split()])
ans = -float("inf")
dp = [[0 for i in range(4)] for j in range(len(matrix)+1)]
for i in range(len(matrix)-1,-1,-1):
    for j in range(len(matrix[0])-1,-1,-1):
        dp[i][j] = -float("inf")
        for k in range(3):
            if j != k:
                dp[i][j] = max(dp[i][j],dp[i+1][k]+matrix[i][j])
        ans = max(ans,dp[i][j])
print(ans)
from functools import reduce
import heapq, sys


input = sys.stdin.readline
N = int(input())
XD = sorted([tuple(map(int, input().split())) for _ in range(N)], key=lambda x: x[0], reverse=True)
P = 998244353


class Node:
    def __init__(self, ch):
        self.ch = ch

    def cal(self):
        if len(self.ch) == 0:
            return 2
        return reduce(lambda a, b: (a * b) % P, [ch.cal() for ch in self.ch]) + 1


hq = []  # (x, Node)
heapq.heapify(hq)
for x, d in XD:
    ch = []
    while len(hq) != 0 and hq[0][0] < x+d:
        ch.append(heapq.heappop(hq)[1])
    heapq.heappush(hq, (x, Node(ch)))

ans = reduce(lambda a, b: (a * b) % P, [node.cal() for x, node in hq])
print(ans)




### FIXED CODE ###

from functools import reduce
import heapq, sys


input = sys.stdin.readline
N = int(input())
XD = sorted([tuple(map(int, input().split())) for _ in range(N)], key=lambda x: x[0], reverse=True)
P = 998244353


class Node:
    def __init__(self, ch):
        self.ch = ch
        if len(self.ch) == 0:
            self.score = 2
        else:
            self.score = reduce(lambda a, b: (a * b) % P, [ch.score for ch in self.ch]) + 1

hq = []  # (x, Node)
heapq.heapify(hq)
for x, d in XD:
    ch = []
    while len(hq) != 0 and hq[0][0] < x+d:
        ch.append(heapq.heappop(hq)[1])
    heapq.heappush(hq, (x, Node(ch)))

ans = reduce(lambda a, b: (a * b) % P, [node.score for x, node in hq])
print(ans)
import sys
def main():
    ans = [0] * 2
    for line in sys.stdin:
        a,b,c = map(int, line.split())
        if a ** 2 + b ** 2 == c ** 2:
            ans[0] += 1
        else:
            ans[1] += 1

    for a in ans:
            print(a)


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
def main():
    r = 0
    d = 0
    for line in sys.stdin:
        A = list(map(int, line.split(",")))
        if A[0] == A[1]:
            d += 1
        else:
            if A[0] ** 2 + A[1] ** 2 == A[2] ** 2:
                r += 1

    print(r)
    print(d)



if __name__ == "__main__":
    main()
from sys import stdin
import heapq
def main():
    #入力
    readline=stdin.readline
    x,y,z,k=map(int,readline().split())
    a=list(map(int,readline().split()))
    a.sort(reverse=True)
    b=list(map(int,readline().split()))
    b.sort(reverse=True)
    c=list(map(int,readline().split()))
    c.sort(reverse=True)

    s={(0,0,0)}
    h=[[-(a[0]+b[0]+c[0]),(0,0,0)]]
    heapq.heapify(h)
    for _ in range(k):
        li=heapq.heappop(h)
        n=-li[0]
        co=li[1]
        print(n)

        if co[0]+1<x:
            co_1=(co[0]+1,co[1],co[2])
            n_1=a[co_1[0]]+b[co_1[1]]+c[co_1[2]]
            n_1=-n_1
        if co[1]+1<y:
            co_2=(co[0],co[1]+1,co[2])
            n_2=a[co_2[0]]+b[co_2[1]]+c[co_2[2]]
            n_2=-n_2
        if co[2]+1<z:
            co_3=(co[0],co[1],co[2]+1)
            n_3=a[co_3[0]]+b[co_3[1]]+c[co_3[2]]
            n_3=-n_3

        if co_1 not in s:
            heapq.heappush(h,[n_1,co_1])
            s.add(co_1)
        if co_2 not in s:
            heapq.heappush(h,[n_2,co_2])
            s.add(co_2)
        if co_3 not in s:
            heapq.heappush(h,[n_3,co_3])
            s.add(co_3)

if __name__=="__main__":
    main()

### FIXED CODE ###

from sys import stdin
def main():
    #入力
    readline=stdin.readline
    x,y,z,k=map(int,readline().split())
    a=list(map(int,readline().split()))
    b=list(map(int,readline().split()))
    c=list(map(int,readline().split()))

    d=list()
    for i in range(x):
        for j in range(y):
            d.append(a[i]+b[j])

    d.sort(reverse=True)
    if x*y>=k:
        d=d[:k]

    e=list()
    for i in range(len(d)):
        for j in range(z):
            e.append(d[i]+c[j])

    e.sort(reverse=True)
    for i in range(k):
        print(e[i])

if __name__=="__main__":
    main()
n=int(input())
a=[]
for _ in range(n):
    a.append(int(input()))

a=sorted(a)
turn=(n-1)//2
pre=a[0]*2
ans=0
for i in range(turn):
    if i%2==0:
        p=a[n-i-1]
        q=a[n-i-2]
        new=p+q
        ans += new-pre
        m=p-a[n-i-3]
    else:
        p=a[i]
        q=a[i+1]
        new=p+q
        ans += pre-new
        m=a[i+2]-p
    pre=new

if n%2==0:
    ans += m

a=sorted(a,reverse=True)
pre=a[0]*2
ans1=0
for i in range(turn):
    if i%2==0:
        p=a[n-i-1]
        q=a[n-i-2]
        new=p+q
        ans1 += pre-new
        m=a[n-i-3]-p
    else:
        p=a[i]
        q=a[i+1]
        new=p+q
        ans1 += new-pre
        m=p-a[i+2]
    pre=new

if n%2==0:
    ans1 += m

las=max(ans,ans1)
print(las)

### FIXED CODE ###

n=int(input())
a=[]
for _ in range(n):
    a.append(int(input()))
     
if n==2:
    print(abs(a[0]-a[1]))
    exit()

a=sorted(a)
turn=(n-1)//2
pre=a[0]*2
ans=0
for i in range(turn):
    if i%2==0:
        p=a[n-i-1]
        q=a[n-i-2]
        new=p+q
        ans += new-pre
        m=p-a[n-i-3]
    else:
        p=a[i]
        q=a[i+1]
        new=p+q
        ans += pre-new
        m=a[i+2]-p
    pre=new

if n%2==0:
    ans += m

a=sorted(a,reverse=True)
pre=a[0]*2
ans1=0
for i in range(turn):
    if i%2==0:
        p=a[n-i-1]
        q=a[n-i-2]
        new=p+q
        ans1 += pre-new
        m=a[n-i-3]-p
    else:
        p=a[i]
        q=a[i+1]
        new=p+q
        ans1 += new-pre
        m=p-a[i+2]
    pre=new

if n%2==0:
    ans1 += m

las=max(ans,ans1)
print(las)