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


N,M = (int(i) for i in input().split())
a = [0] * M
mod = 1000000007
for i in range(M):
    a[i] = int(input())

dp = [1] * (N + 1)

flag = 0
for i in range(N-1):
    if i+1 in a and i in a:
        flag = 1
        break
    elif i+1 in a:
        dp[i+2] = dp[i]
    elif i in a:
        dp[i+2] = dp[i+1]
    else:
        dp[i+2] = (dp[i+1] + dp[i]) % mod

if flag == 1:
    print(0)
else:
    print(dp[N])


### FIXED CODE ###


N,M = (int(i) for i in input().split())
a = [0] * M
mod = 1000000007
for i in range(M):
    a[i] = int(input())
a.append(100000000)
flag = 0
for i in range(M-1):
    if a[i] + 1 == a[i+1]:
        flag = 1
        break

dp = [1] * (N + 1)
tmp = 0

for i in range(N-1):
    if i+1 == a[tmp]:
        dp[i+2] = dp[i]
    elif i == a[tmp]:
        dp[i+2] = dp[i+1]
        tmp += 1
    else:
        dp[i+2] = (dp[i+1] + dp[i]) % mod

if flag == 1:
    print(0)
else:
    print(dp[N])
### BUGGY CODE ###

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
N=int(input())
ans=0
for i in range(1,N+1):
    tmp=i*len(make_divisors(i))
    ans+=tmp
print(ans)

### FIXED CODE ###

def calc(b,e):
  cnt=e//b
  return (b+e)*cnt//2
def II(): return int(input())
N=II()
ans=0
for i in range(1,N+1):  
  ans+=calc(i,N//i*i)
print(ans)
### BUGGY CODE ###

N = int(input())
score = 0

for i in range(1, N):
    score += i

print(score)


### FIXED CODE ###

N = int(input())

print((N)*(N-1)//2)
### BUGGY CODE ###

N=int(input())
l=[]
for i in range(1,N):
    if N%i==0:
        l.append([i,N/i])
L=len(l)
s=[0]*L
for j in range(L):
    s[j]=l[j][0]+l[j][1]
print(int(min(s))-2)

### FIXED CODE ###

N=int(input())
l=[]
for i in range(1,int(N**0.5)+1):
    if N%i==0:
        l.append([i,N/i])
L=len(l)
s=[0]*L
for j in range(L):
    s[j]=l[j][0]+l[j][1]
print(int(min(s))-2)
### BUGGY CODE ###

nq = input().split()
n, q = int(nq[0]), int(nq[1])
s = list(input())
r_li = []
l_li = []
a_renzoku = 0
ac_count = 0
ac_li = []
for i in range(q):
    rl = input().split()
    l_li.append(int(rl[0]))
    r_li.append(int(rl[1]))
for i in range(q):
    count = 0
    j = l_li[i] - 1
    while True:
        if j == r_li[i]:
            break
        else:
            if s[j] == "A":
                if j == r_li[i] - 1:
                    break
                else:
                    if s[j + 1] == "C":
                        count += 1
                        j += 2
                    else:
                        j += 1
            else:
                j += 1
    print(count)


### FIXED CODE ###

nq = input().split()
n, q = int(nq[0]), int(nq[1])
s = list(input())
r_li = []
l_li = []
t_li = []
for i in range(q):
    rl = input().split()
    l_li.append(int(rl[0]))
    r_li.append(int(rl[1]))
count = 0
i = 0
while True:
    if i == n:
        break
    else:
        if s[i] == "A":
            if i == n - 1:
                i += 1
                t_li.append(count)
            else:
                if s[i + 1] == "C":
                    t_li.append(count)
                    count += 1
                    t_li.append(count)
                    i += 2
                else:
                    t_li.append(count)
                    i += 1
        else:
            i += 1
            t_li.append(count)
for i in range(q):
    print(t_li[r_li[i] - 1] - t_li[l_li[i] - 1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
s = input()
s = s.replace('R','0')
s = s.replace('G','1')
s = s.replace('B','2')
s = s.replace('\n','')
s = tuple(map(int,s))
rgb = [[0 for _ in range(3)] for _ in range(n+1)]
for i in range(n):
    for j in range(3):
        rgb[i+1][j] = rgb[i][j]
    rgb[i+1][s[i]] = rgb[i][s[i]] +1
rgb = tuple(rgb)
ans = 0
for i in range(n):
    a = s[i]
    for j in range(i+1,n):
        b = s[j]
        if a != b:
            c = 3 -a- b
            ans += rgb[n][c] - rgb[j+1][c]
            if 2*j-i < n and s[2*j-i] == c:
                ans -= 1

print(ans)


### FIXED CODE ###

import collections
n = int(input())
a = input()
a = a.replace('R','1')
a = a.replace('G','2')
a = a.replace('B','3')
a = tuple(map(int,list(a)))
b = collections.Counter(a)
ans =b[3]*b[1]*b[2]
for i in range(n-2):
    for j in range(i+1,n):
        if a[i] == a[j]:
            continue
        c = j*2 -i
        if c < n:
            if a[i]+a[j]+a[c]==6:
                ans -= 1
        else:
            break
print(ans)
### BUGGY CODE ###

n,k = map(int, input().split())
P = list(map(int, input().split()))
PP = [(i+1)/2 for i in P]
ans = 0
for i in range(n-k+1):
    ans = max(sum(PP[i:i+k]),ans)
print(ans)

### FIXED CODE ###

n,k = map(int, input().split())
P = list(map(int, input().split()))
PP = [(i+1)/2 for i in P]
ans = 0
ttl = 0
for i,p in enumerate(PP):
    ttl += p
    if i >= k:
        ttl -= PP[i-k]
    ans = max(ttl, ans)
print(ans)
### BUGGY CODE ###

n,k = list(map(int, input().split()))
lst = []

for i in range(n):
    a,b = list(map(int, input().split()))
    lst += [a for i in range(b)]
# print(lst)
lst.sort()
print(lst[k-1])

### FIXED CODE ###

n,k = list(map(int, input().split()))
lst = [None for i in range(n)]

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

# print(lst)
lst.sort(key=lambda x:x[0])
# print(lst)

count = 0
for i in range(n):
    count += lst[i][1]
    if count>=k:
        print(lst[i][0])
        exit()
### BUGGY CODE ###

import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
from copy import deepcopy 

MAXN = 1005
MAXV = MAXN * (MAXN - 1)//2
G = [[] for _ in range(MAXV)]

id = [[-1] * MAXN for _ in range(MAXN)]
def toId(i,j):
    if i > j:
        i,j = j,i
    return id[i][j]


finished = [0] * MAXV
dp = [-1] * MAXV
def dfs(v):
    if dp[v] != -1:
        if finished[v] == 0:
            return -1
        return dp[v]
    dp[v] = 0
    for e in G[v]:
        res = dfs(e)
        if res == -1:
            return -1
        dp[v] = max(dp[v],res + 1)
    finished[v] = 1
    return dp[v]


def main():
    n = int(input())
    a = [[int(i) - 1 for i in input().split()] for _ in range(n)]

    v = 0
    for i in range(n):
        for j in range(i + 1,n):
            id[i][j] = v
            v += 1
    
    for i in range(n):
        for j in range(n - 1):
            a[i][j] = toId(i,a[i][j])
        for j in range(n - 2):
            G[a[i][j]].append(a[i][j + 1])
    
    ans = 0
    for i in range(v):
        res = dfs(i)
        if res == -1:
            ans = -1
            break
        ans = max(ans,dfs(i) + 1)
    
    print(ans)

if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
from copy import deepcopy 

MAXN = 1005
MAXV = MAXN * (MAXN - 1)//2
G = [[] for _ in range(MAXV)]

id = [[-1] * MAXN for _ in range(MAXN)]
def toId(i,j):
    if i > j:
        i,j = j,i
    return id[i][j]


finished = [0] * MAXV
dp = [-1] * MAXV
def dfs(v):
    if dp[v] != -1:
        if finished[v] == 0:
            return -1
        return dp[v]
    dp[v] = 0
    for e in G[v]:
        res = dfs(e)
        if res == -1:
            return -1
        dp[v] = max(dp[v],res + 1)
    finished[v] = 1
    return dp[v]


def main():
    n = int(input())
    a = [[int(i) - 1 for i in input().split()] for _ in range(n)]

    v = 0
    for i in range(n):
        for j in range(i + 1,n):
            id[i][j] = v
            v += 1
    
    for i in range(n):
        for j in range(n - 1):
            a[i][j] = toId(i,a[i][j])
        for j in range(n - 2):
            G[a[i][j]].append(a[i][j + 1])
    
    ans = 0
    for i in range(v):
        res = dfs(i)
        if res == -1:
            ans = -1
            break
        ans = max(ans,dfs(i) + 1)
    
    print(ans)

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

from collections import defaultdict
import bisect
N,X = map(int,input().split())
S = list(map(int,input().split()))
S.sort()
mod = 10**9+7

fact_memo = [0]*201
fact_memo[0] = 1
def fact(n):
    if fact_memo[n] == 0:
        fact_memo[n] = n*fact(n-1)%mod
    return fact_memo[n]

fact_inv_memo = [0]*201
fact_inv_memo[0] = 1
def fact_inv(n):
    if fact_inv_memo[n] == 0:
        fact_inv_memo[n] = pow(fact(n),mod-2,mod)
    return fact_inv_memo[n]

dp = defaultdict(lambda :-1)
import sys
sys.setrecursionlimit(100000000)
def rec(n,x):
    if dp[(n,x)] != -1:
        return dp[(n,x)]
    if n == 0:
        dp[(n,x)] = x%S[0]
        return dp[(n,x)]
    s = S[:n+1]
    if x <= s[-1]:
        k = bisect.bisect(s,x)
        if k == 0:
            dp[(n,x)] = x*fact(n+1)%mod
        else:
            dp[(n,x)] = fact(n+1)*fact_inv(k)*rec(k-1,x)%mod
    else:
        res = x%s[0]*fact(n)%mod
        for i in range(1,n+1):
            res += fact(n)*fact_inv(i)*rec(i-1,x%s[i])%mod
        dp[(n,x)] = res%mod
    return dp[(n,x)]

print(rec(N-1,X))

### FIXED CODE ###

from collections import defaultdict
N,X = map(int,input().split())
S = list(map(int,input().split()))
S.sort()
mod = 10**9+7

fact_memo = [0]*201
fact_memo[0] = 1
def fact(n):
    if fact_memo[n] == 0:
        fact_memo[n] = n*fact(n-1)%mod
    return fact_memo[n]

fact_inv_memo = [0]*201
fact_inv_memo[0] = 1
def fact_inv(n):
    if fact_inv_memo[n] == 0:
        fact_inv_memo[n] = pow(fact(n),mod-2,mod)
    return fact_inv_memo[n]

dp = defaultdict(lambda :[-1]*(X+1))
for n in range(N):
    for x in range(X+1):
        if n == 0:
            dp[n][x]=x%S[0]
        else:
            dp[n][x]=(dp[n-1][x%S[n]]+n*dp[n-1][x])%mod

print(dp[N-1][X])
### BUGGY CODE ###

a, b, q = map(int, input().split())
S = [0] * a
T = [0] * b
X = [0] * q
for i in range(a):
  S[i] = int(input())
S = [-10**10*2-1] + S + [10**10*2+1]
for i in range(b):
  T[i] = int(input())
T = [-10**10*2-1] + T + [10**10*2+1]
for i in range(q):
  X[i] = int(input())
#print(S)  
#print(T)  
from bisect import bisect_left
from bisect import bisect_right
for i in range(q):
  s_left = bisect_right(S, X[i]) - 1
  s_right = bisect_right(S, X[i])
  t_left = bisect_right(T, X[i]) - 1
  t_right = bisect_right(T, X[i])
  #print(X[i], S[s_left], S[s_right], T[t_right], T[t_left])
  l_rr = max(S[s_right] - X[i], T[t_right] - X[i])
  l_ll = max(X[i] - S[s_left], X[i] - T[t_left])
  l_rslt = (S[s_right] - X[i]) + (S[s_right] - T[t_left])
  l_rtls = (T[t_right] - X[i]) + (T[t_right] - S[s_left])
  l_lsrt = (X[i] - S[s_left]) + (T[t_right] - S[s_left])
  l_ltrs = (X[i] - T[t_left]) + (S[s_right] - T[t_left])
  print(min(l_rr, l_ll, l_rslt, l_rtls, l_lsrt, l_ltrs))
  

### FIXED CODE ###

a, b, q = map(int, input().split())
S = [0] * a
T = [0] * b
X = [0] * q
for i in range(a):
  S[i] = int(input())
S = [-10**10*2-1] + S + [10**10*2+1]
for i in range(b):
  T[i] = int(input())
T = [-10**10*2-1] + T + [10**10*2+1]
for i in range(q):
  X[i] = int(input())
#print(S)  
#print(T)  
from bisect import bisect_right
for i in range(q):
  x = X[i]
  s_left = bisect_right(S, x) - 1
  s_right = bisect_right(S, x)
  t_left = bisect_right(T, x) - 1
  t_right = bisect_right(T, x)
  sl = S[s_left]
  sr = S[s_right]
  tl = T[t_left]
  tr = T[t_right]
  #print(X[i], S[s_left], S[s_right], T[t_right], T[t_left])
  l_rr = max(sr - x, tr - x)
  l_ll = max(x - sl, x - tl)
  l_rslt = (sr - x) + (sr - tl)
  l_rtls = (tr - x) + (tr - sl)
  l_lsrt = (x - sl) + (tr - sl)
  l_ltrs = (x - tl) + (sr - tl)
  print(min(l_rr, l_ll, l_rslt, l_rtls, l_lsrt, l_ltrs))
### BUGGY CODE ###

import bisect
import heapq
import sys
import itertools
import queue


input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7


class V:
    def __init__(self, f):
        self.f = f
        self.v = None

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n)

    def get(self):
        return self.v


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def P(N):
    D = []
    for n in range(1, int(N ** 0.5) + 1):
        D.append(n)
        if N // n != n:
            D.append(N // n)
    D.sort()
    return D


def main():
    N, K = read_values()
    D = P(N)
    C = [D[i] - D[i - 1] if i != 0 else D[i] for i, d in enumerate(D)]
    dp = [{d: C[i] for i, d in enumerate(D)}] + [
        {d: 0 for d in D} for k in range(K - 1)
    ]
    SS = [[0] + [d for d in D]] + [[0] * (len(D) + 1) for k in range(K - 1)]
    for k in range(1, K):
        for i, d in enumerate(D):
            j = bisect.bisect_left(D, N // d)
            dp[k][d] = SS[k - 1][j + 1] * C[i]
            dp[k][d] %= mod
            SS[k][i + 1] = (SS[k][i] + dp[k][d]) % mod
    print(sum(dp[K - 1][d] for d in D) % mod)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import bisect
import heapq
import sys
import itertools
import queue


input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7


class V:
    def __init__(self, f):
        self.f = f
        self.v = None

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n)

    def get(self):
        return self.v


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def P(N):
    D = []
    for n in range(1, int(N ** 0.5) + 1):
        D.append(n)
        if N // n != n:
            D.append(N // n)
    D.sort()
    return D


def main():
    N, K = read_values()
    D = P(N)
    C = [(D[i] - D[i - 1]) % mod if i != 0 else D[i] for i, d in enumerate(D)]
    dp = [0] * len(D)
    S = [D] + [[0] * len(D) for k in range(K - 1)]
    I = [bisect.bisect_left(D, N // d) for d in D]

    for k in range(1, K):
        for i in range(len(D)):
            j = I[i]
            dp[i] = (S[k - 1][j] * C[i]) % mod
            S[k][i] = (S[k][i - 1] + dp[i]) % mod
    print(S[-1][-1] % mod)


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

N, X, Y = map(int, input().split())
cnt = [0] * (N - 1)

for i in range(1, N + 1):
	for j in range(i + 1, N + 1):
		#X !! Y
		cmb = j - i
		#X -> Y
		XY = abs(X - i) + 1 + abs(Y - j)
		#X <- Y
		YX = abs(Y - i) + 1 + abs(X - j)
		cmb = min(cmb, min(XY, YX))
		cnt[cmb - 1] += 1

for i in cnt:
	print(i)

### FIXED CODE ###

N, X, Y = map(int, input().split())
dis = [0] * (N - 1)

for i in range(1, N):
	for j in range(i + 1, N + 1):
		cmb = min(j - i, abs(X - i) + 1 + abs(Y - j), abs(Y - i) + 1 + abs(X - j))
		dis[cmb - 1] += 1

[print(i) for i in dis]
### BUGGY CODE ###

import bisect
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
BC = []
for _ in range(M):
    BC.append(list(map(int, input().split())))
BC = sorted(BC, key=lambda x: x[1], reverse=True)
for b, c in BC:
    index = bisect.bisect_left(A, c)
    replace = 0
    if index > 0:
        for _ in range(N - index, N):
            A.insert(index, c)
            replace += 1
            if replace == b:
                break

print(sum(A[::-1][:N]))

### FIXED CODE ###

import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
heapq.heapify(A)
BC = []
for _ in range(M):
    BC.append(list(map(int, input().split())))
BC = sorted(BC, key=lambda x: x[1], reverse=True)

card = []
for b, c in BC:
    for _ in range(b):
         my_min = heapq.heappop(A)
         if c > my_min:
             heapq.heappush(A, c)
         else:
              heapq.heappush(A, my_min)
              break

print(sum(A))
### BUGGY CODE ###

import fractions
A, B = map(int, input().split())
C = fractions.gcd(A, B)
pfac = []

def get_primes(n):
  primes = [2]
  for i in range(3, (n+1), 2):
    for p in primes:
      if i % p == 0:
        break
      if i < p ** 2:
        primes.append(i)
        break
    else:
      primes.append(i)
  return primes



for p in get_primes(C):
  if p ** 2 > C:
    break
  if C % p == 0:
    pfac.append(p)
    while C % p == 0:
      C //= p
if C != 1:
  pfac.append(C)


print(len(pfac) + 1)

### FIXED CODE ###

import fractions
import math

A, B = map(int, input().split())
C = fractions.gcd(A, B)
pfac = []

def get_primes(n):
  primes = [2]
  for i in range(3, (n+1), 2):
    for p in primes:
      if i % p == 0:
        break
      if i < p ** 2:
        primes.append(i)
        break
    else:
      primes.append(i)
  return primes

def get_primes2(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n == 1:
        return []
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

for q in get_primes2(min(C, 10**6)):
  if q ** 2 > C:
    break
  if C % q == 0:
    pfac.append(q)
    while C % q == 0:
      C //= q
if C != 1:
  pfac.append(C)


print(len(pfac) + 1)
### BUGGY CODE ###

s = list(input())
for i in range(len(s)):
    if s[i] == "R":
        s[i] = 1
    else:
        s[i] = -1

ans = [0]*len(s)
for i in range(len(s)):
    now = i
    for _ in range(1000):
        now += s[now]
    ans[now] += 1 

an = [str(i) for i in ans]
print(" ".join(an))

### FIXED CODE ###

s = list(input())
ans = [0]*len(s)

i = 0
while i != len(s):
    cnt1 = 0
    cnt2 = 0
    while s[i + cnt1] == "R":
        cnt1 += 1
    ans[i + cnt1] += cnt1//2
    ans[i + cnt1 - 1] += cnt1//2 + cnt1%2
    while s[i + cnt1 + cnt2] == "L":
        cnt2 += 1
        if i + cnt1 + cnt2 == len(s):
            break
    ans[i + cnt1] += cnt2//2 + cnt2%2
    ans[i + cnt1 - 1] += cnt2//2
    i += cnt1 + cnt2

an = [str(i) for i in ans]
print(" ".join(an))
### BUGGY CODE ###

n, m, *a = map(int, open(0).read().split())
a = sorted(a, reverse=True)

for i in range (0,m):
  a[0] = a[0]//2
  a = sorted(a, reverse=True)

print(sum(a))

### FIXED CODE ###

n, m, *a = map(int, open(0).read().split())

a.sort(reverse=True)

if n == 1:
  for i in range (0,m):
    a[0] = a[0]//2
    if a[0] == 0:
      break
else:
  a.append(0)
  biggest = a[0]
  now = 0
  while m > 0:
    a[now] = a[now]//2
    m = m - 1
    biggest = a[0]
    for i in range (n-1):
      if a [i+1] >= biggest and m>0:
        a[i+1] = a[i+1]//2
        m = m -1
      else:
        a.sort(reverse = True)
        break

print(sum(a))
### BUGGY CODE ###

import itertools

N,X,Y=map(int, input().split())

l=list(range(1,N+1))

for k in range(1, N):
    cnt=0
    for p in itertools.combinations(l, 2):
        a=p[1]-p[0]
        b=abs(p[1]-Y)+abs(p[0]-X)+1
        if k==min(a,b):cnt+=1
    print(cnt)

### FIXED CODE ###

import itertools

N,X,Y=map(int, input().split())

l=list(range(1,N+1))
cnt=[0]*(N-1)

for p in itertools.combinations(l, 2):
    a=p[1]-p[0]
    b=abs(p[1]-Y)+abs(p[0]-X)+1
    cnt[min(a,b)-1]+=1

for k in cnt:
    print(k)
### BUGGY CODE ###

from scipy.sparse import*
i=lambda:tuple(map(int,input().split()))
f=csgraph.johnson
n,m,l=i()
d=eval('[0]*-~n,'*-~n)
while m:a,b,c=i();d[a][b]=c;m-=1
d=f(f(d,0)<=l)-1
d[d>n]=-1
for _ in'_'*i()[0]:print(d[i()])

### FIXED CODE ###

from scipy.sparse import*
s=csgraph.floyd_warshall
n,m,l,*t=map(int,open(0).read().split())
d=eval('[9e9]*-~n,'*-~n)
for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=d[b][a]=c
d=s(d)
d[d>l]=9e9
d[d<=l]=1
d=s(d)
d[d>9e9]=9e9
for s,t in zip(*[iter(t[m*3+1:])]*2):print(int(d[s,t]%9e9-1))
### BUGGY CODE ###

N = int(input())
A = list(enumerate(list(map(int, input().split()))))
count = 0
B = sorted(A,key=lambda x:x[1])
h = [x[1] for x in B]
mem = [i+1 for i in range(N-1)]
Min = h[0] + h[1]
Max = h[-1] + h[-2]
for i in range(max(2,Min),min(N,Max+1)):
    for j in range(N-1):
        c = h[j]
        if c >= i:
            break
        else:
            d = i - c
            for k in range(mem[j],N):
                if h[k] == d:
                    if abs(B[j][0]-B[k][0]) == i:
                        count += 1
                elif h[k] > d:
                    mem[j] = k
                    break
print(count)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(enumerate(list(map(int, input().split()))))
b = Counter([x[0]+x[1]+1 for x in A])
c = Counter([x[0]-x[1]+1 for x in A])
count = 0
for x in b.items():
    count += x[1] * c[x[0]]
print(count)
### BUGGY CODE ###

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

stepper = 0
gate = []

for j in range(M):
    gate_1, gate_2 = map(int, input().split())
    gate.append([gate_1, gate_2])


def numJudge(arr, num):
    if arr[0] <= num <= arr[1]:
        return 1
    else:
        return 0


def judge(num):
    num += 1
    num = [num]*M
    counter = map(numJudge, gate, num)
    if sum(list(counter)) == M:
        return 1
    else:
        return 0


ans = map(judge, range(N))
print(sum(list(ans)))
"""
for i in range(N):
    i += 1
    counter = 0
    for k in gate:
        #print(k, i)
        if k[0] <= i <= k[1]:
            counter += 1
    #print(counter, M)
    if counter == M:
        stepper += 1
"""


### FIXED CODE ###

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

stepper = 0
gate = []

for j in range(M):
    gate_1, gate_2 = map(int, input().split())
    gate.append([gate_1, gate_2])

gate_min = 0
gate_max = N

for m in range(M):
    if gate[m][0] > gate_min:
        gate_min = gate[m][0]

    if gate[m][1] < gate_max:
        gate_max = gate[m][1]

#print(gate_min, gate_max)
for k in range(N):
    k = k+1
    if gate_min <= k <= gate_max:
        stepper += 1

print(stepper)
### BUGGY CODE ###

from collections import defaultdict
n,k=map(int,input().split())
xy=[list(map(int,input().split())) for _ in range(n)]
xwl=dict((c[0],i) for i,c in enumerate(xy))
ywl=dict((c[1],i) for i,c in enumerate(xy))
x=list(xwl.keys())
y=list(ywl.keys())
x.sort()
y.sort()

xdict=dict()
ydict=dict()
xdict[x[0]]=[1<<xwl[x[0]],0]
ydict[y[0]]=[1<<ywl[y[0]],0]
size=lambda x:sum(x>>i&1 for i in range(n))
minus=lambda x,y:(x|y)^y
for i in range(1,n):
  xdict[x[i]]=[xdict[x[i-1]][0]|(1<<xwl[x[i]]), xdict[x[i-1]][1]|(1<<xwl[x[i-1]])]
  ydict[y[i]]=[ydict[y[i-1]][0]|(1<<ywl[y[i]]), ydict[y[i-1]][1]|(1<<ywl[y[i-1]])]

cand=[(x[t]-x[s])*(y[v]-y[u]) for s in range(n) for t in range(n) \
 for u in range(n) for v in range(n) if size(minus(xdict[x[t]][0],xdict[x[s]][1])&\
                minus(ydict[y[v]][0],ydict[y[u]][1]))>=k and s<t and u<v]

print(min(cand))


### FIXED CODE ###

from collections import defaultdict
def main():
  n,k=map(int,input().split())
  xy=[list(map(int,input().split())) for _ in range(n)]
  x=[p[0] for p in xy]
  y=[p[1] for p in xy]
  x.sort()
  y.sort()
  
  s1=[[0]*n for _ in range(n)]
  s2=[[0]*n for _ in range(n)]
  s3=[[0]*n for _ in range(n)]
  s4=[[0]*n for _ in range(n)]
  for i in range(n):
    for j in range(n):
        for p in xy:
            if p[0]<=x[i] and p[1]<=y[j]:
              s1[i][j]+=1
              s2[i][j]+=(p[0]<x[i])
              s3[i][j]+=(p[1]<y[j])
              s4[i][j]+=(p[0]<x[i])*(p[1]<y[j])
  ans=float('inf')
  for s in range(n):
    for t in range(s+1,n):
      for u in range(n):
        for v in range(u+1,n):
          if s1[t][v]-s3[t][u]-s2[s][v]+s4[s][u]>=k:
            ans=min(ans,(x[t]-x[s])*(y[v]-y[u]))
  print(ans)

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

N = int(input())
A = sorted(list(map(int, input().split())),reverse=True)
ring = [A[0]]
score = [A[0]] #ringのi-1とiの間に割り込んだ時に入るフレンドリーさ
s = 0

for i in range(1,N):
    s += max(score)
    j = score.index(max(score))
    ring.insert(j,A[i])
    score.insert(j,A[i])
    score[j+1] = A[i]
    # print("ring")
    # print(ring)
    # print(score)
    # print(s)

print(s)

### FIXED CODE ###

import math
N = int(input())
A = sorted(list(map(int, input().split())),reverse=True)
s = A[0]

for i in range(1,N-1):
    s += A[math.ceil(i/2)]

print(s)