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

import sys

# import math
# import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
# INF = sys.maxsize
# MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    d = na()

    for i in range(n):
        tmp_d = d[:i] + d[i + 1:]
        tmp_d.sort()
        print(tmp_d[n // 2 - 1])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

# import math
# import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
# INF = sys.maxsize
# MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    d = na()

    tmp_d = sorted(d)

    front = tmp_d[n//2-1]
    rear = tmp_d[n//2]

    for num in d:

        if front>=num:
            print(rear)
        else:
            print(front)


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

s = input()

dp1 = {'A': 0, 'AB': 0, 'ABC': 0}

c = 1000000000 + 7

count = 0
for i in range(len(s)):
    dp2 = {'A': 0, 'AB': 0, 'ABC': 0}

    if s[i] == '?':
        dp2['A'] = dp1['A']*3 + (3**count)
    elif s[i] == 'A':
        dp2['A'] = dp1['A'] + (3**count)
    else:
        dp2['A'] = dp1['A']

    if s[i] == '?':
        dp2['AB'] = dp1['AB']*3 + dp1['A']
    elif s[i] == 'B':
        dp2['AB'] = dp1['AB'] + dp1['A']
    else:
        dp2['AB'] = dp1['AB']

    if s[i] == '?':
        dp2['ABC'] = dp1['ABC']*3 + dp1['AB']
    elif s[i] == 'C':
        dp2['ABC'] = dp1['ABC'] + dp1['AB']
    else:
        dp2['ABC'] = dp1['ABC']

    if s[i] == '?':
        count += 1

    for j in dp2.keys():
        dp2[j] = dp2[j] % c
    dp1 = dp2
    #print(i, dp1)

print(dp1['ABC'])


### FIXED CODE ###

s = input()

dp1 = {'A': 0, 'AB': 0, 'ABC': 0}
dp2 = {'A': 0, 'AB': 0, 'ABC': 0}

c = 1000000000 + 7
n = len(s)
tmp = [1]*n
for i in range(1, n):
    tmp[i] = (tmp[i-1] * 3)%c
#print(tmp)

count = 0
for i in range(n):
    #dp2 = {'A': 0, 'AB': 0, 'ABC': 0}

    # if s[i] == '?':
    #     dp2['A'] = dp1['A']*3 + (3**count)
    # elif s[i] == 'A':
    #     dp2['A'] = dp1['A'] + (3**count)
    # else:
    #     dp2['A'] = dp1['A']
    #
    # if s[i] == '?':
    #     dp2['AB'] = dp1['AB']*3 + dp1['A']
    # elif s[i] == 'B':
    #     dp2['AB'] = dp1['AB'] + dp1['A']
    # else:
    #     dp2['AB'] = dp1['AB']
    #
    # if s[i] == '?':
    #     dp2['ABC'] = dp1['ABC']*3 + dp1['AB']
    # elif s[i] == 'C':
    #     dp2['ABC'] = dp1['ABC'] + dp1['AB']
    # else:
    #     dp2['ABC'] = dp1['ABC']
    #
    # if s[i] == '?':
    #     count += 1

    if s[i] == '?':
        dp2['A'] = dp1['A']*3 + tmp[count]
        dp2['AB'] = dp1['AB']*3 + dp1['A']
        dp2['ABC'] = dp1['ABC']*3 + dp1['AB']
        count += 1
    elif s[i] == 'A':
        dp2['A'] = dp1['A'] + tmp[count]
        dp2['AB'] = dp1['AB']
        dp2['ABC'] = dp1['ABC']
    elif s[i] == 'B':
        dp2['A'] = dp1['A']
        dp2['AB'] = dp1['AB'] + dp1['A']
        dp2['ABC'] = dp1['ABC']
    elif s[i] == 'C':
        dp2['A'] = dp1['A']
        dp2['AB'] = dp1['AB']
        dp2['ABC'] = dp1['ABC'] + dp1['AB']

    # for j in dp2.keys():
    #     dp2[j] = dp2[j] % c\
    # dp1 = dp2

    dp1['ABC'] = dp2['ABC'] % c
    dp1['AB'] = dp2['AB'] % c
    dp1['A'] = dp2['A'] % c

    #print(i, dp1)

print(dp1['ABC'])
### BUGGY CODE ###

from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 1000
for n in range(2**N):
    n = bin(n)[2:]
    n = '0'*(N-len(n))+n
    l = []
    for i in range(N):
        if n[i]=='0':
            l.append([A[i],i])
        else:
            l.append([B[i],i+1])
    inversion = 0
    for i in range(N):
        if inversion>=ans:
            break
        for j in range(i+1,N):
            if l[i][0]>l[j][0]:
                inversion += 1
    if inversion>=ans:
        continue
    l.sort()
    d = defaultdict(list)
    for i in range(N):
        v,j = l[i]
        if (i-j)%2==1:
            d[v].append(i)
    possible = True
    for v in d:
        if len(d[v])%2==1:
            possible = False
        else:
            for i in range(len(d[v])//2):
                if (d[v][2*i+1]-d[v][2*i])%2==1:
                    inversion += d[v][2*i+1]-d[v][2*i]
                else:
                    possible = False
                    break
        if not possible:
            break
    if possible:
        ans = min(ans,inversion)

if ans == 1000:
    ans = -1
print(ans)

### FIXED CODE ###

from collections import defaultdict
from operator import itemgetter
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 1000
for n in range(2**N):
    n = bin(n)[2:]
    if n.count('1')%2!=0:
        continue
    n = '0'*(N-len(n))+n
    l = []
    for i in range(N):
        if n[i]=='0':
            l.append([A[i],i])
        else:
            l.append([B[i],i+1])
    inversion = 0
    for i in range(N):
        if inversion>=ans:
            break
        for j in range(i+1,N):
            if l[i][0]>l[j][0]:
                inversion += 1
    if inversion>=ans:
        continue
    l.sort(key=itemgetter(0))
    d = defaultdict(list)
    for i in range(N):
        v,j = l[i]
        if (i-j)%2==1:
            d[v].append(i)
    possible = True
    for v in d:
        if len(d[v])%2==1:
            possible = False
        else:
            for i in range(len(d[v])//2):
                if (d[v][2*i+1]-d[v][2*i])%2==1:
                    inversion += d[v][2*i+1]-d[v][2*i]
                else:
                    possible = False
                    break
        if not possible:
            break
    if possible:
        ans = min(ans,inversion)

if ans == 1000:
    ans = -1
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100000)

N, K = list(map(int, input().split()))
ab = [[0, 0] for i in range(N-1)]
for i in range(N-1):
    ab[i][0], ab[i][1] = (list(map(int, input().split())))

ki = []

for i in range(N):
    ki.append(dict())
    ki[-1]["eda"] = []

for i in range(N-1):
    ki[ab[i][0] - 1]["eda"].append([ab[i][1] - 1])
    ki[ab[i][1] - 1]["eda"].append([ab[i][0] - 1])

def P(m ,n):
    if m <= 0 or n <= 0:
        return 0
    else:
        num = 1
        for i in range(n):
            num *= m-i
        return num

def saiki(i, base, ki):
    num = 1
    eda_num = len(ki[i]["eda"])-1
    if eda_num == 0:
        return num
    num *= P(K-2, eda_num)

    for edge in ki[i]["eda"]:
        if edge[0] != base:
            num *= saiki(edge[0], i, ki)

    num = num % 1000000007
    return num

total_num = K
if len(ki[0]["eda"]) != 0:
    total_num *= P(K-1, len(ki[0]["eda"]))
    for edge in ki[0]["eda"]:
        total_num *= saiki(edge[0], 0, ki)
        total_num = total_num % 1000000007
        if total_num == 0:
            break

print(total_num)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
INF=10**9+7
def LI(): return list(map(int, sys.stdin.readline().split()))
 
def main():
    n, k = LI()
    graph=[[] for i in range(n)]
    for i in range(n-1):
        a,b=LI()
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
    ans=1
    check=[False]*n
    stack=[0]
    ans=1
    while len(stack)>0:
        x=stack.pop()
        check[x]=True
        count=0
        for i in graph[x]:
            if not check[i]:
                count+=1
                stack.append(i)
        if x==0:
            temp=1
            for i in range(count):
                temp=temp*(k-1-i)%INF
            ans=ans*temp%INF
        else:
            temp=1
            for i in range(count):
                temp=temp*(k-2-i)%INF
            ans=ans*temp%INF
    print((ans*k)%INF)
 
 
if __name__ == "__main__":
    main()
### BUGGY CODE ###

from collections import defaultdict
N,M = map(int,input().split())

D = defaultdict(lambda: N+1)
for i in range(M):
    a,b = map(int,input().split())
    if b<D[a]:D[a]=b
        
side_b = []
ans = 0
for i in range(1,N+1):
    if i in side_b:
        side_b = []
        ans += 1
    side_b.append(D[i])
    #print(i,side_b)
    
print(ans)

### FIXED CODE ###

from collections import defaultdict
N,M = map(int,input().split())

D = defaultdict(lambda: N+1)
for i in range(M):
    a,b = map(int,input().split())
    if b<D[a]:D[a]=b
        
side_b_min = N+1
ans = 0
for i in range(1,N+1):
    if i == side_b_min:
        side_b_min = N+1
        ans += 1
    if D[i] < side_b_min: side_b_min = D[i]
    #print(i,side_b_min)
    
print(ans)
### BUGGY CODE ###

from sys import stdin
input = stdin.readline
n = int(input())
pn = list(map(int, input().split()))
ans = 1
for i in range(n-1):
  if min(pn[:i+1]) >= pn[i+1]:
    ans +=1
print(ans)


### FIXED CODE ###

n = int(input())
plist = list(map(int,input().split()))
min = n + 1
count = 0
for i in range(n):
  if plist[i] <= min:
    min = plist[i]
    count += 1
print(count)
### BUGGY CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 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 _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)

ans = []
lines_dict =None
d=None
def main():
    global AB, PX
    if 'LOCAL' in os.environ:
        N = 2* 10** 5
        Q = 2 * 10 ** 5
        AB = [[i, i + 1] for i in range(1, N)]
        PX = [[i, 10] for i in range(Q)]
    else:
        N, Q = LI()
        AB = {}
        PX = {}
        for i in range(1, N+1):
            AB[i] = set()
            PX[i] = 0
        for i in range(N-1):
            #  AB.append(LI())
            a, b = LI()
            AB[a].add(b)
            AB[b].add(a)

        for i in range(Q):
            p, x = LI()
            PX[p] += x

        dfs(1, -1)
        for i in sorted(PX.keys()):
            print(PX[i], end=' ')
        #  ans = [0 for _ in range(N)]

def dfs(parent, parent_parent):
    for node in AB[parent]:
        if node != parent_parent:

            if node not in PX.keys():
                PX[node] = 0
            PX[node] += PX[parent]
            dfs(node, parent)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 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 _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)

if 'LOCAL' in os.environ:
    N = 2* 10** 5
    Q = 2 * 10 ** 5
    AB = [[i, i + 1] for i in range(1, N)]
    PX = [[i, 10] for i in range(Q)]
else:
    N, Q = LI()
    AB = []
    PX = []
    for i in range(N-1):
        AB.append(LI())

    for i in range(Q):
        PX.append(LI())


"""
そもそも各頂点の部分木をdictに入れましょうか？
参照するような形で。
2には3
3には4,5
4,5はNoneだと、参照しやすいか？

カウントを若い順にやっていく
"""
AB = sorted(AB, key=lambda x: x[0])
perr('AB')
perr(AB)
d = {}
for p, x in PX:
    if p not in d.keys():
        d[p] = 0
    d[p] += x
for a, b in AB:
    if b not in d.keys():
        d[b] = 0
    if a not in d.keys():
        d[a] = 0
    d[b] += d[a]
for i in range(1, N+1):
    print(d[i], end=' ')
### BUGGY CODE ###

N=int(input())
for n in range(1,N+1):
    a=n/6

    saidai=int(a**0.5)+20
    answer=0
    for z in range(1,saidai+1):
        if 3+z**2+2*z>n:
            break
        for y in range(1,z+1):
            if y**2+z**2+1+y+z+y*z>n:
                break
            for x in range(1,y+1):
                if x**2+y**2+z**2+x*y+y*z+z*x==n:
                    if x==y==z:
                        answer+=1
                        break
                    elif x==y or y==z or z==x:
                        answer+=3
                        break
                    else:
                        answer+=6
                        break
    print(answer)


### FIXED CODE ###

import math
N=int(input())
for n in range(1,N+1):
    saidai=math.floor((abs(n-2))**0.5)
    saishou=math.ceil((n//6)**0.5)
    answer=0
    for z in range(saishou,saidai+1):
        if 3+z**2+2*z>n:
            break
        for y in range(1,z+1):
            if y**2+z**2+1+y+z+y*z>n:
                break
            for x in range(1,y+1):
                if x**2+y**2+z**2+x*y+y*z+z*x>n:
                    break

                if x**2+y**2+z**2+x*y+y*z+z*x==n:
                    if x==y==z:
                        answer+=1
                        break
                    elif x==y or y==z or z==x:
                        answer+=3
                        break
                    else:
                        answer+=6
                        break
    print(answer)
### BUGGY CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9]*n
dp[0]=0
k=min(n,k)
for i in range(n):
    for j in range(i-k,i):
        dp[i]=min(dp[i],abs(h[i]-h[j])+dp[j])
print(dp[-1])

### FIXED CODE ###

import numpy as np
n,k=map(int,input().split())
h=np.array(list(map(int,input().split())))
dp=np.zeros(n,dtype=int)
for i in range(1,n):
    s=max(0,i-k)
    dp[i]=min(dp[s:i]+abs(h[s:i]-h[i]))
print(dp[-1])
### BUGGY CODE ###

n = int(input())
a = [int(x) for x in input().split()]

res = 0

a.sort()
cnt = 0
nex = 0
find = a[0]
for i in range(len(a)):
  find = a[nex]
  for v in a[nex:]:
    if v == find:
      cnt += 1
      nex += 1
    else:
      break
  if cnt >= find:
    res += cnt - find
  else:
    res += cnt
  cnt = 0
  if nex > len(a) - 1:
    break

print(res)


### FIXED CODE ###

n = int(input())
a = [int(x) for x in input().split()]

res = 0

find = a[0]
cnt = {a[0]: 0}
for v in a:
  if v not in cnt:
    cnt[v] = 0
  cnt[v] += 1

for k,v in cnt.items():
  if v >= k:
    res += v - k
  else:
    res += v

print(res)
### BUGGY CODE ###

n,q = map(int, input().split())
s = input()
for _ in range(q):
    l,r = map(int,input().split())
    ss = s[l-1:r]
    cnt = len([e for e in ss.replace('AC', '1') if e == '1'])
    print(cnt)

### FIXED CODE ###

n,q = map(int, input().split())
s = input()
lst = []
num = 0
for i in range(n):
    if i == 0:
        lst.append(num)
        continue
    ss = s[i-1:i+1]
    if ss == 'AC':
        num += 1
    lst.append(num)
for _ in range(q):
    l,r = map(int,input().split())
    ans = lst[r-1] - lst[l-1]
    print(ans)
### BUGGY CODE ###

n = int(input())
A = list(map(int,input().split()))
X = []
A_sum = sum(A)

for i in range(n):
    temp = A_sum
    for j in range(i+1,n+i,2):
        temp -= 2*A[j % n]
    X.append(temp)

for i,x in enumerate(X):
    if i == n-1:
        print(x)
    else:
        print(x,end=" ")


### FIXED CODE ###

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

x = sum(A)
for i in range(1,n,2):
    x -= 2*A[i] 

print(x,end=" ")

for i in range(n-1):
    x = 2*A[i]-x
    print(x,end=" ")
### BUGGY CODE ###

#問題 D
import numpy as np
N, W = map(int,input().split())
VAL = [0]*(W+1)
val = [0]*(W+1)
for n in range(N):
    w,v = map(int,input().split())
    for weight in range(w,W+1):
        val[weight] = max(VAL[weight],VAL[weight-w]+v)
    VAL = val[:]
print(VAL[W])
    # listをコピーするときは注意　https://qiita.com/utgwkk/items/5ad2527f19150ae33322

### FIXED CODE ###

import numpy as np
N, W = map(int,input().split())
#普通に書くとTLEだったのでNumpy化
dp = np.zeros(W+1,dtype=int)
for i in range(N):
    w,v = map(int,input().split())
    dp[w:] = np.maximum(dp[w:],dp[:-w]+v)
print(int(dp[-1]))
### BUGGY CODE ###

def main():
    s = list(input())[::-1]
    ary_mod = [0] * 2019
    ary_mod[0] = 1
    now = 0

    for i, ss in enumerate(s):
        now += (int(ss) * 10 ** i) % 2019
        remind = now % 2019
        ary_mod[remind] += 1
    ans = 0
    for i, n in enumerate(ary_mod):
        ans += (n*(n-1)) // 2
    print(ans)
if __name__=='__main__':
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)


S = input()
N = len(S)
P = 2019

if P == 2 or P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i + 1
    print(ans)
    sys.exit()

num = [0] * P
num[0] = 1
now, ans = 0, 0
_10 = 1
for i in range(N-1, -1, -1):
    now = (now + int(S[i]) * _10) % P
    _10 *= 10
    _10 %= P
    ans += num[now]
    num[now] += 1

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

import numpy as np
H, W = map(int, input().split())
red_map = np.array([input().split() for i in range(H)], dtype="int")
blue_map = np.array([input().split() for i in range(H)], dtype="int")
sub_map = abs(red_map - blue_map)
dp = [[[] for i in range(W)] for i in range(H)]

for i in range(H):
  for j in range(W):
    if not i and not j:
      dp[i][j].append(sub_map[i][j])
      dp[i][j].append(-sub_map[i][j])
    if i > 0 and j > 0:
      for k in dp[i-1][j]:
        dp[i][j].append(k + sub_map[i][j])
        dp[i][j].append(k - sub_map[i][j])
      for l in dp[i][j-1]:
        dp[i][j].append(l + sub_map[i][j])
        dp[i][j].append(l - sub_map[i][j])
    if i > 0 and not j:
      for m in dp[i-1][j]:
        dp[i][j].append(m + sub_map[i][j])
        dp[i][j].append(m - sub_map[i][j])
    if j > 0 and not i:
      for n in dp[i][j-1]:
        dp[i][j].append(n + sub_map[i][j])
        dp[i][j].append(n - sub_map[i][j])

print(min(np.abs(dp[H-1][W-1])))

### FIXED CODE ###

import numpy as np
H, W = map(int, input().split())
red_map = np.array([input().split() for i in range(H)], dtype="int")
blue_map = np.array([input().split() for i in range(H)], dtype="int")
sub_map = abs(red_map - blue_map)
dp = [[2020]*W for i in range(H)]
max_deviation = 2**(80*(H+W))

for i in range(H):
  for j in range(W):
    if not i and not j:
      dp[i][j] = (max_deviation<<sub_map[i][j] | max_deviation>>sub_map[i][j])
    if i > 0:
      dp[i][j] |= (dp[i-1][j]<<sub_map[i][j] | dp[i-1][j]>>sub_map[i][j])
    if j > 0:
      dp[i][j] |= (dp[i][j-1]<<sub_map[i][j] | dp[i][j-1]>>sub_map[i][j])
      
pre_ans = dp[H-1][W-1]>>80*(H+W)
pre_ans_bit = format(pre_ans&-pre_ans, "b")
ans = len(pre_ans_bit)-1
print(ans)
### BUGGY CODE ###

import math
def main():
    N = int(input())
    ans = 0
    for c in range(1, N):
        tmp = 0
        sqrtnc = int(math.sqrt(N - c))
        for b in range(1, sqrtnc + 1):
            if ((N - c) // b) * b == N - c:
                tmp += 1
        ans += tmp * 2
        if sqrtnc ** 2 == N - c:
            ans -= 1
    return ans

if __name__ == '__main__':
    print(main())

### FIXED CODE ###

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError("n is int-type.")
    if n < 2:
        raise ValueError("n is more than 2")
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data
 
p_list = get_sieve_of_eratosthenes(10**3)
 
def factorization_counta(n):
    arr = []
    temp = n
    for i in p_list:
        if i * i > n:
            break
        elif temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append(cnt)
            
    if temp != 1:
        arr.append(1)
    if arr == []:
        arr.append(1)
    return arr

def main():
    N = int(input())
    ans = 1
    for c in range(2, N):
        p = factorization_counta(c)
        tmp = 1
        for v in p:
            tmp *= (v + 1)
        ans += tmp
    return ans
 
if __name__ == '__main__':
    print(main())
### BUGGY CODE ###

n = int(input())
p = list(map(int, input().split()))[::-1]

x = list(range(1, n+1))

cnt = 0
for i in p:
    if x.index(i) == 0:
        cnt += 1
    x.remove(i)

print(cnt)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
ans = 1
mi = p[0]
for i in range(1, n):
    if mi > p[i]:
        mi = p[i]
        ans += 1
print(ans)
### BUGGY CODE ###

n = int(input())
ans = 0

if n == 1:
  ans = 0
else:
  for i in range(1,n):
    ans += i
  
print(ans)

### FIXED CODE ###

n = int(input())
 
ans = (n*(n-1)//2)
 
print(int(ans))
### BUGGY CODE ###

import fractions
x=0
K=int(input())
for i in range(1,K+1):
  for j in range(1,K+1):
    for h in range(1,K+1):
      if i==j and j==h:
        x=x+i
      elif i==j or j==h:
        x=x+fractions.gcd(i,h)
      else:
        x=x+fractions.gcd(i,fractions.gcd(j,h))
print(x)

### FIXED CODE ###

import math
x=0;y=0
K=int(input())
for i in range(1,K+1):
  for j in range(1,K+1):
    y=math.gcd(i,j)
    for h in range(1,K+1):
      x=x+math.gcd(y,h)
print(x)
### BUGGY CODE ###

from fractions import gcd
from functools import reduce

MOD = 10**9+7

def lcm(x, y):
    return (x * y) // gcd(x, y)

n = int(input())
a = [int(_) for _ in input().split()]
LCM = reduce(lambda x, y: lcm(x, y), a)

ans = 0
for i in a:
    ans += LCM // i
    ans %= MOD
print(ans)


### FIXED CODE ###

from fractions import gcd
from functools import reduce

MOD = 1000000007

def lcm(x, y):
    return (x * y) // gcd(x, y)

n = int(input())
a = [int(_) for _ in input().split()]
LCM = reduce(lcm, a)

arr = [LCM // _ for _ in a]
print(sum(arr) % MOD)
### BUGGY CODE ###

N,M,R = map(int,input().split())
r = list(map(int,input().split()))
S = [[]for i in range(N)]
for i in range(M):
    a,b,c = map(int,input().split())
    S[a-1].append([b-1,c])
    S[b-1].append([a-1,c])
d = [[float('inf')]*N for i in range(N)]
queue = []
for i in range(N):
    queue = [i]
    d[i][i] = 0
    while queue !=[]:
        hoge = []
        for q in queue:
            for next,c in S[q]:
                if d[i][next] > d[i][q]+c:
                    hoge.append(next)
                    d[i][next] = d[i][q]+c
        queue = hoge
def func(x,l):
    if l == []:
        return 0
    ans = float('inf')
    for i in range(len(l)):
        ans =min(ans,func(l[i],l[:i]+l[i+1:]) + d[x-1][l[i]-1])
    return ans
ans = float('inf')
for i in r:
    ans = min(ans,func(i,r))
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N,M,R = map(int,input().split())
r = list(map(int,input().split()))
S = [[]for i in range(N)]
for i in range(M):
    a,b,c = map(int,input().split())
    S[a-1].append([b-1,c])
    S[b-1].append([a-1,c])
d = [[float('inf')]*N for i in range(N)]
queue = []
hoge = [0]*(M)
for i in range(N):
    queue = [i]
    d[i][i] = 0
    while queue !=[]:
        l = 0
        for q in queue:
            for next,c in S[q]:
                if d[i][next] > d[i][q]+c:
                    d[i][next] = d[i][q]+c
                    if not(next in hoge[:l]):
                        hoge[l] = next
                        l += 1
        queue = hoge[:l]
def func(x,l):
    if l == []:
        return 0
    ans = float('inf')
    for i in range(len(l)):
        ans =min(ans,func(l[i],l[:i]+l[i+1:]) + d[x-1][l[i]-1])
    return ans
ans = float('inf')
for i in r:
    ans = min(ans,func(i,r))
print(ans)
### BUGGY CODE ###

A, B = map(int, input().split())
ans = 0
for i in range(A, B+1):
    ans = ans^i
print(ans)


### FIXED CODE ###

A, B = map(int, input().split())
ans = 0
flag = False
if A%2 == 1:
    flag = True
    A += 1
diff = B-A+1
if diff%4 == 0:
    ans = 0
elif diff%4 == 1:
    ans = B
elif diff%4 == 2:
    ans = 1
else:
    ans = B^1
if flag: ans = ans^(A-1)
print(ans)