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

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

    if a[i] != max(a):
        
        b.append([abs((max(a)/2)-a[i]),i])

print('{} {}'.format(max(a),a[sorted(b)[0][1]]))


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = []
c = max(a)
d = -100
for i in range(n):

    if a[i] != c:

        if d == -100:

            d = abs((c/2)-a[i])
            e = i 

        else:

            if abs((c/2)-a[i]) < d:

                d = abs((c/2)-a[i]) 
                e = i 
        
        
print('{} {}'.format(c,a[e]))
### BUGGY CODE ###

n = int(input())
k = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans = k.index(i+1)+1
    print(ans,end=" ")

### FIXED CODE ###

n = int(input())
k = list(map(int,input().split()))
l = [0 for i in range(n)]
for i in range(n):
    l[k[i]-1] = i + 1

for i in range(n):
    print(l[i],end=" ")
### BUGGY CODE ###

from functools import reduce
n = int(input())
a = list(map(int, input().split()))

ans = reduce(lambda x, y: x*y, a)

if ans > 10**18:
    print(-1)
    exit()

print(ans)


### FIXED CODE ###

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


ans = 1
if 0 in a:
    print(0)
    exit()

for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()

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

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = input()
flag = [True] * 10
check = defaultdict(lambda : 0)
ans = 0
for i in range(n):
    if flag[int(s[i])]:
        for j in range(i+1, n):
            for k in range(j+1, n):
                x = s[i] + s[j] + s[k]
                if check[x]:
                    continue
                check[x] = 1
                ans += 1
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
#三井住友信託銀行プログラミングコンテスト2019 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def C(n,r):
    return math.factorial(n)//math.factorial(n-r)//math.factorial(r)

n = I()
s = input()
t = list(map(int,list(s)))
ans = 0
for i in range(10):
    for j in range(n):
        if i == t[j]:
            tmp = j
            break
    else:
        continue
    for j in range(100):
        if len(str(j)) == 2:
            x,y = list(str(j))
        else:
            x,y = '0',str(j)
        flg = False
        for k in range(tmp+1,n):
            if flg and y == str(t[k]):
                ans += 1
                break
            if x == str(t[k]):
                flg = True
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

N, M, K = map(int, input().split())
edges = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].add(b)
    edges[b].add(a)

block_edges = [set() for _ in range(N)]
for _ in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    block_edges[c].add(d)
    block_edges[d].add(c)

visited = [False] * N
cnt = 0

def dfs(u, s):
    if visited[u]:
        return

    visited[u] = True
    for v in edges[u]:
        if visited[v]:
            continue
        if v == s:
            continue

        if v in block_edges[s] or v in edges[s]:
            pass
        else:
            global cnt
            cnt += 1

        dfs(v, s)


ans = []
for i in range(N):
    visited = [False] * N
    cnt = 0
    for v in edges[i]:
        dfs(v, i)
    ans.append(cnt)
print(*ans)


### FIXED CODE ###

class UnionFind:
    def __init__(self, n):
        self.d = [-1] * n

    def find(self, x):
        if self.d[x] < 0:
            return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.d[self.find(x)]


N, M, K = map(int, input().split())
NMAX = 100005
deg = [0] * NMAX
to = [[] for _ in range(NMAX)]
uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    deg[a] += 1
    deg[b] += 1
    uf.unite(a, b)
for i in range(K):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)
anss = []
for i in range(N):
    ans = uf.size(i) - 1 - deg[i]
    for u in to[i]:
        if uf.same(i, u):
            ans -= 1
    anss.append(ans)
print(" ".join(map(str, anss)))
### BUGGY CODE ###

import itertools

S = list(map(str,input()))

counter = 0

set = list(itertools.combinations(range(len(S)),2))

for i in range(len(set)):
    s = int("".join(S[int(set[i][0]):int(set[i][1])+1]))
    if s % 2019 == 0:
        counter += 1

print(counter)

### FIXED CODE ###

S = list(map(int,input()))[::-1] #逆順

counter = 0
amari = [0]*2019
amari[0] = 1

s,d = 0,1

for i in S:
    s += i *d
    amari[s%2019] += 1
    d *= 10
    d %= 2019


for i in range(2019):
    counter += amari[i] * (amari[i]-1) / 2


print(int(counter))
### BUGGY CODE ###

N = int(input())
X = list(map(int,input().split()))
S = []
dp = [1]
mod = 10**9+7
for i in range(N):
    t = i+1
    dp.append(dp[i]*t)
W = []
for i in range(1,N):
    y = dp[N-1]//i
    y % mod
    W.append(y)
ans = 0
for i in range(N-1):
    x = X[i]
    S.append(X[N-1]-x)
ans = 0
for i in range(N-1):
    x = S[i]
    t = i + 1
    ans += W[i]*x%mod
print(ans%mod)

### FIXED CODE ###

N = int(input())
X = list(map(int,input().split()))
S = []
dp = [1]
mod = 10**9+7
for i in range(N):
    t = i+1
    dp.append(dp[i]*t%mod)
def power(a,b):
    if b == 0:
        return 1
    if b % 2 == 0:
        d = power(a,b//2)
        return d*d%mod
    elif b % 2 == 1:
        return a*power(a,b-1)%mod
W = []
for i in range(1,N):
    y = dp[N-1]*power(i,mod-2)%mod
    W.append(y)
ans = 0
for i in range(N-1):
    x = X[i]
    S.append(X[N-1]-x)
ans = 0
for i in range(N-1):
    x = S[i]
    t = i + 1
    ans += W[i]*x%mod
print(ans%mod)
### BUGGY CODE ###

import sys
def main():
    input = sys.stdin.readline
    N, K = map(int, input().rstrip().split())
    
    BL = (300000).bit_length()
    WIDTH = pow(2, BL)
    BUFSIZE = pow(2, BL+1) - 1
    BASE = BUFSIZE - WIDTH
    
    buf = [0] * BUFSIZE
    
    def update(i, x):
        i += BASE
        buf[i] = x
        i = (i-1) // 2
        while i >= 0:
            ix2 = 2*i
            v1 = buf[ix2+1]
            v2 = buf[ix2+2]
            buf[i] = v1 if v1 > v2 else v2
            i = (i-1) // 2
    
    def _search(l, width, i, q_left, q_right):
        if q_right < l or l + width - 1 < q_left:
            return 0
        if q_left <= l and l + width - 1 <= q_right:
            return buf[i]
        nwidth = width // 2
        ix2 = i*2
        c1 = _search(l, nwidth, ix2+1, q_left, q_right)
        c2 = _search(l+nwidth, nwidth, ix2+2, q_left, q_right)
        return c1 if c1 > c2 else c2
    
    for _ in range(N):
        a = int(input().rstrip())
        maxlen = _search(0, WIDTH, 0, a-K, a+K)
        update(a, maxlen+1)
    print(_search(0, WIDTH, 0, 0, 300000))

main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
N, K = map(int, input().rstrip().split())

BL = (300001-1).bit_length()
WIDTH = pow(2, BL)
BUFSIZE = pow(2, BL+1) - 1
BASE = BUFSIZE - WIDTH
DEFAULT = 0

buf = [DEFAULT] * BUFSIZE

def update(i, x):
    i += BASE
    buf[i] = x
    i = (i-1) // 2
    while i >= 0:
        buf[i] = compare(buf[2*i+1], buf[2*i+2])
        i = (i-1) // 2

# [q_left, q_right]
def search(left, right):
    ansl = ansr = DEFAULT
    left += BASE
    right += BASE
    while left < right:
        if not (left & 1):
            ansl = compare(ansl, buf[left])
            left += 1
        if right & 1:
            ansr = compare(ansr, buf[right])
            right -= 1
        left = (left-1) // 2
        right = (right-1) // 2
    if left == right:
        ansl = compare(ansl, buf[left])
    return compare(ansl, ansr)

def compare(v1, v2):
    return v1 if v1 > v2 else v2

for _ in range(N):
    a = int(input().rstrip())
    maxlen = search(max(0, a-K), min(a+K, 300000))
    update(a, maxlen+1)
print(search(0, 300000))
### BUGGY CODE ###

n,m = map(int,input().split())
li=[[] for _ in range(m)]
for _ in range(n):
  ai,bi = map(int,input().split())
  if ai <= m:
    li[ai-1].append(bi)
pos = []
sm = 0
for i in range(m):
  pos.extend(li[i])
  pos.sort(reverse=True)
  if len(pos) > m-i:
    pos = pos[:m-i]
  if len(pos) > 0:
    s = pos.pop(0)
    sm += s
print(sm)
    
  

### FIXED CODE ###

from heapq import heappush,heappop
n,m = map(int,input().split())
x = []
xa = x.append
for _ in range(n):
  ai,bi = map(int,input().split())
  xa((ai,bi))
x.sort(key=lambda a:a[0])
y = []
count = 0
j = 0
for i in range(1,m+1):
  while x[j][0] == i:
    heappush(y,-x[j][1])
    if j+1 < n:
      j += 1
    else:
      break
  if len(y) != 0:
    count -= heappop(y)
print(count)
### BUGGY CODE ###

A, B = map(int, input().split())
xor = 0

for i in range(A, B + 1):
        xor ^= i

print(xor)

### FIXED CODE ###

def XOR_sum(n):
    m = n + 1
    if m % 4 == 0:
        return 0
    elif m % 4 == 1:
        return n
    elif m % 4 == 2:
        return 1
    else:
        return 1 ^ n
        

A, B = map(int, input().split())

a = XOR_sum(A - 1)
b = XOR_sum(B)

print(a ^ b)
### BUGGY CODE ###

n= int(input())
l= []
for _ in range(n):
	s= input()
	if s in l:
		pass
	else:
		l.append(s)
print(len(l))

### FIXED CODE ###

n= int(input())
l= set()
for _ in range(n):
	s= input()
	l.add(s)
print(len(l))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(3*10**5)

N, M = map(int,input().split())
adj = [[] for i in range(N+1)]
for i in range(M):
	u, v, w = map(int,input().split())
	adj[u].append(v)
	adj[v].append(u)

vis = [False for i in range(N+1)]
def dfs(u):
	if vis[u]:
		return
	vis[u] = True
	for v in adj[u]:
		dfs(v)

ans = 0
for u in range(1,N+1):
	if not vis[u]:
		ans += 1
		dfs(u)

print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(3*10**5)

N, M = map(int,input().split())
adj = [[] for i in range(N+1)]
for i in range(M):
	u, v, w = map(int,input().split())
	adj[u].append(v)
	adj[v].append(u)

vis = [False for i in range(N+1)]
def bfs(s):
	frontier = [s]
	ptr = 0
	while ptr < len(frontier):
		u = frontier[ptr]
		if not vis[u]:
			vis[u] = True
			for v in adj[u]:
				if not vis[v]:
					frontier.append(v)
		ptr += 1
ans = 0
for u in range(1,N+1):
	if not vis[u]:
		ans += 1
		bfs(u)

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

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

count = 0

for idx, a in enumerate(A):
    for i in range(idx+a+1, N):
        if a + A[i] == i - idx:
            count += 1

print(count)

### FIXED CODE ###

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

count = 0

count_dict = collections.defaultdict(int)

for idx, a in enumerate(A):
    count_dict[idx-a] += 1

for idx, a in enumerate(A):
    if idx+a in count_dict:
        count += count_dict[idx+a]
        continue
    # for i in range(idx+a+1, N):
    #     if a + A[i] == i - idx:
    #         count += 1
    #         count_dict[idx+a+1] += 1
# print(count_dict)

print(count)
### BUGGY CODE ###

N = int(input())
P_ls = list(map(int, input().split(' ')))
rst = 0
for i in range(N):
    val = P_ls[i]
    is_suc = True
    for j in P_ls[: i + 1]:
        if j < val:
            is_suc = False
            break
    if is_suc:
        rst += 1
print(rst)

### FIXED CODE ###

N = int(input())
P_ls = list(map(int, input().split(' ')))
rst, min_val = 0, 10 ** 6
for i in P_ls:
    if min_val >= i:
        rst += 1
        min_val = i
print(rst)
### BUGGY CODE ###

Q=int(input())
q=[]
a=[]
b=0
n=0
def dist(A,x,n):
  ret=0
  for i in range(n):
    ret+=abs(A[i]-x)
  return ret
for i in range(Q):
  q.append(list(map(int,input().split())))
  if q[i][0]==2:
    if len(a)%2==0:
      x=a[len(a)//2-1]
      fx=dist(a,x,n)+b
      print(x,fx)
    else:
      x=a[len(a)//2]
      fx=dist(a,x,n)+b
      print(x,fx)
  else:
    n+=1
    a.append(q[i][1])
    b+=q[i][2]
    a.sort()

### FIXED CODE ###

import heapq
q=int(input())
L=[]
R=[]
heapq.heapify(L)
heapq.heapify(R)
fx=0
for i in range(q):
  Q=list(map(int,input().split()))
  if Q[0]==1:
    a,b=Q[1],Q[2]
    heapq.heappush(L,-a)
    heapq.heappush(R,a)
    l=-heapq.heappop(L)
    r=heapq.heappop(R)
    if l==a and r==a:
      heapq.heappush(L,-l)
      heapq.heappush(R,r)
    else:
      fx+=abs(r-l)
      heapq.heappush(L,-r)
      heapq.heappush(R,l)
    x=-L[0]
    fx+=b
  else:
    print(x,fx)
### BUGGY CODE ###

from collections import deque
h, w = map(int,input().split())
ch, cw = map(int,input().split())
Dh, Dw = map(int,input().split())

M = ['##' + input() + '##' for _ in range(h)]
for i in range(2):
    M.insert(0,'#'*(w+4))
    M.append('#'*(w+4))

INF = float('inf')
cost = [[INF for _ in range(w+4)] for _ in range(h+4)]
cost0 = deque()
ans = -1

cost0.append((ch+1, cw+1, 0))
cost[ch+1][cw+1] = 0

move = [(1,0),(0,1),(-1,0),(0,-1)]
warp = [(i,j) for i in range(-2,3) for j in range(-2,3) if (i,j) not in [(0,0)] + move]

cost1 = deque()

while cost0:
    h, w, c = cost0.popleft()
    cost1.append((h, w, c))
    
    for i,j in move:
        dh = h + i
        dw = w + j
        if M[dh][dw] == '.' and c < cost[dh][dw]: #コストが高いところから低いところに戻らないようにするため
            cost[dh][dw] = c
            cost0.appendleft((dh, dw, cost[dh][dw]))
    
    if len(cost0) == 0:
        while cost1:
            h, w, c = cost1.popleft()
            for i,j in warp:
                dh = h + i
                dw = w + j
                if M[dh][dw] == '.' and c+1 < cost[dh][dw]:  #無駄なワープをなくすため
                    cost[dh][dw] = c+1
                    cost0.append((dh, dw, cost[dh][dw]))
    if cost[Dh+1][Dw+1] != INF:
        ans = cost[Dh+1][Dw+1]

print(ans)

### FIXED CODE ###

from collections import deque
def solve():  
    h, w = map(int,input().split())
    ch, cw = map(int,input().split())
    Dh, Dw = map(int,input().split())
    
    M = ['##' + input() + '##' for _ in range(h)]
    for i in range(2):
        M.insert(0,'#'*(w+4))
        M.append('#'*(w+4))
    
    INF = float('inf')
    cost = [[INF for _ in range(w+4)] for _ in range(h+4)]
    cost0 = deque()
    ans = -1
    
    cost0.append((ch+1, cw+1, 0))
    cost[ch+1][cw+1] = 0
    
    move = [(1,0),(0,1),(-1,0),(0,-1)]
    warp = [(i,j) for i in range(-2,3) for j in range(-2,3) if (i,j) not in [(0,0)] + move]
    
    cost1 = deque()
    
    while cost0:
        h, w, c = cost0.popleft()
        cost1.append((h, w, c))
        
        for i,j in move:
            dh = h + i
            dw = w + j
            if M[dh][dw] == '.' and c < cost[dh][dw]: #コストが高いところから低いところに戻らないようにするため
                cost[dh][dw] = c
                cost0.appendleft((dh, dw, cost[dh][dw]))
        
        if len(cost0) == 0:
            while cost1:
                h, w, c = cost1.popleft()
                for i,j in warp:
                    dh = h + i
                    dw = w + j
                    if M[dh][dw] == '.' and c+1 < cost[dh][dw]:  #無駄なワープをなくすため
                        cost[dh][dw] = c+1
                        cost0.append((dh, dw, cost[dh][dw]))
        if cost[Dh+1][Dw+1] != INF:
            ans = cost[Dh+1][Dw+1]
    
    print(ans)

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

N, Q = map(int, input().split())
S = input()
for i in range(Q):
  l, r = map(int, input().split())
  print(S[l - 1 : r].count("AC"))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
A = [0] * (N + 1)
for i in range(1, N):
  if S[i - 1] == "A" and S[i] == "C":
    A[i + 1] = A[i] + 1
  else:
    A[i + 1] = A[i]
for i in range(Q):
  l, r = map(int, input().split())
  print(A[r] - A[l])
### BUGGY CODE ###

n=int(input())

v=list(map(int,input().split()))
c=list(map(int,input().split()))

x=0
for i in range(2**n):
    cost=0
    value=0
    for j in range(n):
        if i>>j&1:
            cost+=c[j]
            value+=v[j]
    else:
        if value-cost>x:
            x=value-cost
            


print(x)
         

### FIXED CODE ###

n=int(input())

v=list(map(int,input().split()))
c=list(map(int,input().split()))

ans=0
for i in range(n):
    if v[i]-c[i]>=1:
        ans+=v[i]-c[i]

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

n = int(input())
a = list(int(x) for x in input().split())
x = 0

for i in range(n):
    if (a.pop(0) in a) is True:
        print("NO")
        x = 1
        break

if x == 0:
    print("YES")


### FIXED CODE ###

n = int(input())
a = list(int(x) for x in input().split())
x = 0
 
a.sort()
for i in range(n-1):
    if a[-1] - a[-2] == 0:
        print("NO")
        x = 1
        break
    a.pop()
 
if x == 0:
    print("YES")
### BUGGY CODE ###

def solve():
    import sys

    input = sys.stdin.readline

    n, t = map(int, input().split())  # t - 1まで注文OK
    ab = tuple(tuple(map(int, input().split())) for _ in range(n))

    ret = 0
    for last_dish, (_, last_b) in enumerate(ab):
        dp = [0] * t
        # dp[皿ID][時間] = 最大おいしさ
        # dp[T-1] + 残りで一番美味しいもの
        # 先にどの皿を最後に食べるか決めておいて、それ以外でdp
        # 3000回dp

        for dish, (a, b) in enumerate(ab):
            if dish == last_dish:
                continue
            for t_ in range(t - 1, a - 1, -1):
                dp[t_] = max(dp[t_], dp[t_ - a] + b)
        ret = max(ret, max(dp) + last_b)
    return ret


print(solve())


### FIXED CODE ###

def solve():
    from collections import namedtuple
    import sys

    input = sys.stdin.readline
    Dish = namedtuple('Dish', 'idx cost pt')

    n, t = map(int, input().split())
    dishes = []
    for idx in range(1, n + 1):
        cost, pt = map(int, input().split())
        dishes.append(Dish(idx=idx, cost=cost, pt=pt))

    dp_ht = [[0] * t for _ in range(n + 2)]  # head->tail
    dp_th = [[0] * t for _ in range(n + 2)]  # tail->head
    # dp[注文可能な範囲の端][完食にかかる総時間]:= 美味しさの最大値

    for dish in dishes:
        for cost_ in range(t):
            if cost_ >= dish.cost:
                dp_ht[dish.idx][cost_] = max(dp_ht[dish.idx - 1][cost_],
                                             dp_ht[dish.idx - 1][cost_ - dish.cost] + dish.pt)
            else:
                dp_ht[dish.idx][cost_] = dp_ht[dish.idx - 1][cost_]

    for dish in reversed(dishes):
        for cost_ in range(t):
            if cost_ >= dish.cost:
                dp_th[dish.idx][cost_] = max(dp_th[dish.idx + 1][cost_],
                                             dp_th[dish.idx + 1][cost_ - dish.cost] + dish.pt)
            else:
                dp_th[dish.idx][cost_] = dp_th[dish.idx + 1][cost_]

    ret = 0
    for last_dish in dishes:
        for cost_ in range(t):
            ret = max(ret, dp_ht[last_dish.idx - 1][cost_] + dp_th[last_dish.idx + 1][t - 1 - cost_] + last_dish.pt)
    return ret


print(solve())
### BUGGY CODE ###

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

ans = 0
for i,p in enumerate(Ps):
  if p==min(Ps[:i+1]):
    ans += 1
    
print(ans)

### FIXED CODE ###

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

ans = 0
min_val = Ps[0]
for i,p in enumerate(Ps):
  if p<=min_val:
    ans += 1
    min_val = p
print(ans)
### BUGGY CODE ###


Q=int(input())
LR=[]
L,R=0,0
for i in range(Q):
    l,r=map(int,input().split())
    L,R=max(L,l),max(R,r)
    LR.append([l,r])

M=R+1
lst=[0 for i in range(M)]
sosuu=set([2])
count=0
for i in range(3,M,2):
    flag=0
    for m in sosuu:
        if i%m==0:
            flag=1
            break

    if not flag:
        sosuu.add(i)
        if (i+1)//2 in sosuu:
            count+=1
    lst[i]=count

for l,r in LR:
    print(lst[r]-lst[max(l-2,0)])


### FIXED CODE ###


Q=int(input())
LR=[]
L,R=0,0
for i in range(Q):
    l,r=map(int,input().split())
    L,R=max(L,l),max(R,r)
    LR.append([l,r])
M=R+1
lst=[0 for i in range(M)]
sosuu=set([2])
count=0
for i in range(3,M//2+1,2):
    flag=0
    for m in sosuu:
        if i%m==0:
            flag=1
            break

    if not flag:
        sosuu.add(i)
        if (i+1)//2 in sosuu:
            count+=1
    lst[i]=count

A=M//2
if not (M//2)%2:
    A-=1

while lst[A]:
    A+=2
#print(A,"A",sosuu,count)
for i in range(A,M,2):
    if (i+1)//2 in sosuu:
        flag=0
        for m in sosuu:
            if i%m==0:
                flag=1
                break
        if not flag:
            sosuu.add(i)
            count+=1
    lst[i]=count
#print(lst)
for l,r in LR:
    print(lst[r]-lst[max(l-2,0)])
### BUGGY CODE ###

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

if N < M : 

    X = list(map(int, input().split()))
    
    X = sorted(X)
    
    move = []
    
    for i in range(len(X)-1) : 
        move.append(X[i+1] -X[i])
        
    # print(move)
    
    for i in range(N-1) : 
        move.pop(move.index(max(move)))
    
    # print(move)
    
    sum = 0
    
    for i in move : 
        sum += i

else : 
    sum = 0
    
print(sum)

### FIXED CODE ###

from collections import deque

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

if N < M : 

    X = sorted(list(map(int, input().split())))
    
    move = []
    
    for i in range(len(X)-1) : 
        move.append(X[i+1] -X[i])
        
    # print(move)

    move = sorted(move)    

    # print(move)
    
    sum = 0
    
    for i in range(M-N) : 
        sum += move[i]

else : 
    sum = 0
    
print(sum)
### BUGGY CODE ###

def gcd(a, b):
        while a != b:
                if a > b :
                        a -= b
                else:
                        b -= a
        return a

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

print(3*(N - gcd(N, X)))


### FIXED CODE ###

def gcd(a, b):
        while a != b:
                if a == 0:
                        return b
                elif b == 0:
                        return a
                if a > b :
                        a %= b
                else:
                        b %= a
        return a

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

print(3*(N - gcd(N, X)))