Harryxun/stf_run huggingface dataset:
N = int(input())
A = sorted([int(i) for i in input().split()])

M = 0
ans = []

if A[0] >= 0:
    ans.append((A[0], A[-1]))
    M = A[0]-A[-1]
    for i in range(1, N-1):
        if i != N-2:
            ans.append((M, A[i]))
            M -= A[i]
        else:
            ans.append((A[i], M))
            M = A[i]-M
elif A[-1] < 0:
    ans.append((A[0], A[-1]))
    M = A[0]-A[-1]
    for i in range(1, N-1):
        ans.append(M, A[i])
        M -= A[i]
else:
    exit()

print(M)
for t in ans:
    print(*t)


### FIXED CODE ###

import bisect

N = int(input())
A = sorted([int(i) for i in input().split()])

zp = bisect.bisect_left(A, 0)
ans = []

M = A[0]
for i in range(max(zp, 1), N-1):
    ans.append((M, A[i]))
    M -= A[i]

ans.append((A[N-1], M))
M = A[N-1]-M

for i in range(1, min(zp, N-1)):
    ans.append((M, A[i]))
    M -= A[i]


print(M)
for a, b in ans:
    print(a, b)
n = input()
a = list(map(int, input().split()))
for i in range(n):
    while True:
        a[i] *= 1/2
        if a[i]%2!=0 || a[i] = 0:
            break

print(min(a))


### FIXED CODE ###

print(input().count("1"))
n, m = map(int,input().split())
lst = list(map(int,input().split()))
lst.sort()
lst.reverse()
x = sum(lst)
if (lst[m] < x/4/m):
  print("No")
else:
  print("Yes")


### FIXED CODE ###

n, m = map(int,input().split())
lst = list(map(int,input().split()))
lst.sort()
lst.reverse()
x = sum(lst)
if (lst[m - 1] < x/4/m):
  print("No")
else:
  print("Yes")
N = int(input())
A = [int(input()) for i in range(N)]

def insertion_sort(A, N, diff, cnt):
    for i in range(diff, N):
        tmp_num = A[i]
        j = i - diff
        while j >= 0 and A[j] > tmp_num:
            A[j+diff] = A[j]
            j = j - diff
            cnt += 1
        A[j+diff] = tmp_num
    return cnt

if __name__ == "__main__":
    cnt = 0
    divide_cnt = 0
    diffs = []
    quotient = N
    while True:
        quotient = quotient // 2
        if quotient == 1:
            break
        diffs.append(quotient)
        divide_cnt += 1
    diffs.append(1)
    divide_cnt += 1
    for diff in diffs:
        cnt = insertion_sort(A, N, diff, cnt)
    print(divide_cnt)
    print(" ".join(map(str, diffs)))
    print(cnt)
    for num in A:
        print(num)



### FIXED CODE ###

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

def insertion_sort(A, N, diff, cnt):
    for i in range(diff, N):
        tmp_num = A[i]
        j = i - diff
        while j >= 0 and A[j] > tmp_num:
            A[j+diff] = A[j]
            j = j - diff
            cnt += 1
        A[j+diff] = tmp_num
    return cnt

if __name__ == "__main__":
    cnt = 0
    diffs = []
    h = 1
    while h <= N:
        diffs.append(h)
        h = h*3 + 1
    diffs.reverse()
    diffs_cnt = len(diffs)
    for diff in diffs:
        cnt = insertion_sort(A, N, diff, cnt)
    print(diffs_cnt)
    print(" ".join(map(str, diffs)))
    print(cnt)
    for num in A:
        print(num)
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

def check(ar):
    cnt = 0
    for j in range(M):
        count = 0
        for k in ks[1::]:
            if ar[k-1] == 1:
                count += 1
        if count%2 == p[j]:
            cnt += 1
    return (cnt == M)


def dfs(n, ar):
    if n == 0:
        if check(ar):
            return 1
        else:
            return 0
    else:
        return dfs(n-1, ar.append(0)) + dfs(n-1, ar.append(1))
arr = []
ans = dfs(N, arr)
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    cnt = 0
    for j in range(M):
        count = 0
        for k in ks[j][1::]:
            if (i >> k-1)&1 == 1:
                count += 1
        if count%2 == p[j]:
            cnt += 1
    if cnt == M:
        ans += 1
print(ans)
import sys
import numba as nb

input = sys.stdin.readline

@nb.njit
N, W = map(int, input().split())
x = [tuple(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i, (w, v) in enumerate(x, 1):
    dpi = dp[i]
    dpim = dp[i-1]    
    for j in range(1, W + 1):
        if w <= j:
            a = dpim[j - w] + v
            if a > dpim[j]:
                dpi[j] = a
            else:
                dpi[j] = dpim[j]
        else:
            dpi[j] = dpim[j]

print(dp[-1][W])

### FIXED CODE ###

#import
#import math
#import numpy as np
#= int(input())
#= input()
N, W = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]

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

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, W + 1):
        dp[i][j] = dp[i - 1][j]
        if i != 0 and x[i - 1][0] <= j:
            dp[i][j] = max(dp[i][j], dp[i-1][j-x[i-1][0]] + x[i-1][1])

print(dp[-1][W])
ls = list(input())
l = len(ls)
from collections import Counter

for i in range(l):
    ls.pop(-1)
    ls.pop(-1)
    c = Counter(ls)
    if all(j%2==0 for j in c.values()):
        print(len(ls))
        break
    


### FIXED CODE ###

ls = [int(x) for x in input().split()]
print(sum(ls)-max(ls))
import sys
from collections import Counter
from math import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
C = Counter()
for i in range(N):
    a, b = MAP()
    g = gcd(a, b)
    ga, gb = a // g, b // g
    C[((a < 0) ^ (b < 0), abs(ga), abs(gb))] += 1

ans = 1
for k, v in C.items():
    if v == 0:
        continue
    op, a, b = k
    ans *= pow(2, C[(op, a, b)], MOD) + pow(2, C[(1-op, b, a)], MOD) - 1
    ans %= MOD
    if (1-op, b, a) in C:
        C[(1-op, b, a)] = 0
print((ans-1)%MOD)


### FIXED CODE ###

import sys
from collections import Counter
from math import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
C = Counter()
zero = 0
for i in range(N):
    a, b = MAP()
    if a == b == 0:
        zero += 1
    elif a == 0:
        C[(0, 1, 0)] += 1
    elif b == 0:
        C[(1, 0, 1)] += 1
    else:
        g = gcd(a, b)
        ga, gb = a // g, b // g
        C[((a < 0) ^ (b < 0), abs(ga), abs(gb))] += 1

ans = 1
for k, v in C.items():
    if v == 0:
        continue
    op, a, b = k
    ans *= pow(2, C[(op, a, b)], MOD) + pow(2, C[(1-op, b, a)], MOD) - 1
    ans %= MOD
    if (1-op, b, a) in C:
        C[(1-op, b, a)] = 0
print((zero+ans-1)%MOD)
a,p = map(int,input().split())
ans = (2*a + P)//2
print(ans)

### FIXED CODE ###

a,p = map(int,input().split())
ans = (3*a + p)//2
print(ans)
K = map(int, input())

odd_number = K // 2　+ 1
even_number = K // 2

print(odd_number*even_number)


### FIXED CODE ###

K = int(input())
if K%2 == 0:
    odd_number = K // 2
elif K%2 == 1:    
    odd_number = K // 2 + 1
even_number = K // 2 

print(odd_number*even_number)
N, Y = map(int, input().split())

for s in N+1:
  for g in (N-s):
    i = N - s - g
    if 1000*s + 5000*g + i*10000 == Y:
      print(s, g, i, sep=" ")
      exit()
print(-1, -1, -1, sep=" ")


### FIXED CODE ###

N, Y = map(int, input().split())
 
for s in range(N+1):
  for g in range(N-s+1):
    i = N - s - g
    if 1000*s + 5000*g + i*10000 == Y:
      print(i, g, s, sep=" ")
      exit()
print(-1, -1, -1, sep=" ")
N = int(input())
A = map(int,input().split())
B = map(int,input().split())
C = map(int,input().split())

ful = sum(B)

for i in range(N-1):
  if (A[i+1]-A[i]) == 1:
    ful += C[A[i]]

print(ful)

### FIXED CODE ###

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

ful = sum(B)

for i in range(N-1):
  if (A[i+1]-A[i]) == 1:
    ful += C[A[i]-1]

print(ful)
import numpy as np
n,k = map(int,input().split())
p = list(map(int,input().split()))
p = np.array(p)
e = (p+1)/2
sum_e = []
sum_e.append(np.sum(e[:k]))
for i in range(n-k):
    sum_e.append(sum_e[-1]-e[i]+e[k+i])
print(max(sum_e))

### FIXED CODE ###

import numpy as np
n,k = map(int,input().split())
p = list(map(int,input().split()))
p = np.array(p)
e = (p+1)/2
sum_e = []
sum_e.append(np.sum(e[:k]))
for i in range(n-k):
    sum_e.append(sum_e[-1]-e[i]+e[k+i])
print(max(sum_e))
special_moves = input().split(" ")

_, special_moves = int(inputs[0]), int(inputs[1])

health= input().split(" ")
health= [int(h) for h in health]
health.sort(reverse=True)
print(sum(health[special_moves:]))

### FIXED CODE ###

from sys import stdin

def main():
    n,m = map(int,stdin.readline().split())
    l = list(map(int,stdin.readline().split()))
    l.sort()
    aco = 0
    for i in range(n-m):
        aco+= l[i]
    print(aco)
        
main()
s=input()
print("a" if s=s.lower() else "A")

### FIXED CODE ###

s=input()
print("a" if s == s.lower() else "A")
n = int(input())
a = list(map(int, input().split()))
z = sum(a)
ln = []
x = 0
for i in range(1, n):
    x += a[i]
    ln.append(abs(z - 2 * a)
print(min(ln))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
z = sum(a)
ln = []
x = 0
for i in range(n - 1):
    x += a[i]
    ln.append(abs(z - 2 * x))
print(min(ln))
def powermod(a, p, mod):
    if p == 0:
        return 1
    elif p % 2 == 0:
        return (powermod(a, p//2, mod) ** 2) % mod
    else:
        return ((powermod(a, (p-1)//2, mod) ** 2) % mod) * a % mod

def combinationmod(n,r):
    mod = 10 ** 9 + 7
    factorial = 1
    for i in range(n):
        factorial = (factorial * (i+1)) % mod
        if i+1 == r:
            fact_1 = factorial
        if i+1 == n-r:
            fact_2 = factorial
        if i+1 == n:
            fact_0 = factorial
    return fact_0 * powermod(fact_1,mod-2,mod) % mod * powermod(fact_2,mod-2,mod) % mod
    
X,Y = map(int,input().split())
if (X + Y) % 3 == 0 and X <= 2 * Y and 2 * X >= Y:
    turns = (X + Y) // 3
    print(combinationmod(turns, min(X,Y) - turns))
else:
    print(0)

### FIXED CODE ###

def powermod(a, p, mod):
    if p == 0:
        return 1
    elif p % 2 == 0:
        return (powermod(a, p//2, mod) ** 2) % mod
    else:
        return ((powermod(a, (p-1)//2, mod) ** 2) % mod) * a % mod

def combinationmod(n,r):
    if r == 0 or n == r:
        return 1
    mod = 10 ** 9 + 7
    factorial = 1
    for i in range(n):
        factorial = (factorial * (i+1)) % mod
        if i+1 == r:
            fact_1 = factorial
        if i+1 == n-r:
            fact_2 = factorial
        if i+1 == n:
            fact_0 = factorial
    return fact_0 * powermod(fact_1,mod-2,mod) % mod * powermod(fact_2,mod-2,mod) % mod
    
X,Y = map(int,input().split())
if (X + Y) % 3 == 0 and X <= 2 * Y and 2 * X >= Y:
    turns = (X + Y) // 3
    print(combinationmod(turns, min(X,Y) - turns))
else:
    print(0)
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
li = na()
list.sort(li)
ls = []
for i in range(len(li)-1):
    ls.append(li[i+1]-li[i])
for j in range(n - 1):
    ls.remove(max(ls))
print(sum(ls))

### FIXED CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
li = na()
ls = []
list.sort(li)
for i in range(len(li) - 1):
    ls.append(li[i + 1] - li[i])
ls = sorted(ls, reverse=True)
print(sum(ls[n-1:]))
from fractions import gcd
import sys
input = sys.stdin.readline
A, B = map(int, input().split())

count = 0
tmp = 1

for i in range(1, min(A, B)**0.5+1):
    if A%i == 0 and B%i == 0 and gcd(i, tmp) == 1:
        tmp *= i
        count += 1
print(count)


### FIXED CODE ###

N = int(input())

if N%2 == 0:
    print(0.5)
else:
    print((N//2+1)/N)
import sys
import numpy as np

MOD = 10 ** 9 + 7

n, *a = map(int, sys.stdin.read().split())
a = np.array(a, dtype=np.int64)

powmod = [None] * 100
powmod[0] = 1
for i in range(60):
    powmod[i+1] = powmod[i] * 2 % MOD

def main():
    b = a >> np.arange(60).reshape(-1, 1) & 1
    x = np.count_nonzero(b, axis=1)
    y = n - x
    x *= y
    x *= powmod[:60]
    x %= MOD
    ans = np.sum(x) % MOD
    return ans

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

### FIXED CODE ###

import sys
import numpy as np

MOD = 10 ** 9 + 7

N, *A = map(int, sys.stdin.read().split())
A = np.array(A, dtype=np.int64)

def main():
    answer = 0
    for n in range(60):
        B = (A >> n) & 1
        x = np.count_nonzero(B)
        y = N - x
        x *= y
        x *= pow(2, n, MOD)
        answer += x
    answer %= MOD
    return answer

if __name__ == '__main__':
    ans = main()
    print(ans)
import sys
n,a,b = map(int,input().split())
if a == 0:
    print(0)
elif b == 0:
    print(n)
elif a + b>n:
    print(a)
else:
    c = n//(a+b)
    d = n%(a+b)
    if a>d:
        print(c*a+d)
    else:
        print(c*a + a)

### FIXED CODE ###

s = input()
l = set(s)
if len(l) == 1:
    print("No")
else:
    print("Yes")
a = input()
b = a.sprit()
if b[0] == b[1]:
     if b[1] == b[2]:
         print('Yes')
     else:
         print('No')
else:
     print('No')

### FIXED CODE ###

a = input()
b = a.split()
if b[0] == b[1]:
    if b[1] == b[2]:
        print('Yes')
    else:
        print('No')
else:
    print('No')
def solv():
    s = ''.join(sorted(input()))
    t = ''.join(sorted(input()))[::-1]

    if(s<t):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    solv()

### FIXED CODE ###

import math

def solv():
    a, b = map(int, input().split())
    x = (a + b)/2
    if (math.floor(x * 10) % 10 >= 5):
        print(math.floor(x)+1)
    else:
        print(math.floor(x))

if __name__ == '__main__':
    solv()
N, K=map(int,input().split())
arr = list(map(int,input().split()))
if(K>= N):
  print('0')
else:
  if (K > 0):
    new_arr = sorted(arr)
    ans = new_arr[:-K]
  else:
    ans = arr
print(sum(ans))


### FIXED CODE ###

N, K=map(int,input().split())
arr = list(map(int,input().split()))
if(K>= N):
  print('0')
else:
  if (K > 0):
    new_arr = sorted(arr)
    arr = new_arr[:-K]
  print(sum(arr))
H, W = map(int, input().split())

if H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    S_list = []
    for i in range(1, H-1):
        w = W//2
        S_A = i*W
        S_B = (H-i)*w
        S_C = (H-i)*(W-w)
        S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
    for i in range(1, W-1):
        h = H//2
        S_A = i*H
        S_B = (W-i)*h
        S_C = (W-i)*(H-h)
        S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
    print(min(S_list)) 
    

### FIXED CODE ###

H, W = map(int, input().split())

S_list = []
for h in range(1, H):
    w = W//2
    S_A = h*W
    S_B = (H-h)*w
    S_C = (H-h)*(W-w)
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
for h in range(1, H):
    S_A = h*W
    S_B = ((H-h)//2)*W
    S_C = -(-(H-h)//2)*W
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
H, W = W, H
for h in range(1, H):
    w = W//2
    S_A = h*W
    S_B = (H-h)*w
    S_C = (H-h)*(W-w)
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
for h in range(1, H):
    S_A = h*W
    S_B = ((H-h)//2)*W
    S_C = -(-(H-h)//2)*W
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
print(min(S_list))
N,M = [int(i) for i in input().split()]
A = []
for _ in range(M):
    A.append(int(input()))
def fib_memo(n):
    memo = [0]*(n+1)
    def _fib(n):
        if n <= 2:
            return n
        if memo[n] != 0:
            return memo[n]
        memo[n] = _fib(n-1) + _fib(n-2)
        return memo[n]
    return _fib(n)
cnt = 1
for a in range(len(A)+1):
    if a == 0:
        if A[a] == 1:
            width = 1
        else:
            width = A[a]-1
    elif a > 0 and a < M:
        width = A[a] - A[a-1] - 2
    elif a == (M):
        width = N-A[a-1]-1
    if width < 0:
        tmp = 0
        cnt = 0
        break
    else:
        tmp = fib_memo(width)%1000000007
    cnt = (tmp*cnt)%1000000007
print(cnt)

### FIXED CODE ###

mod = 1000000007
N,M = [int(i) for i in input().split()]
A = []
for _ in range(M):
    A.append(int(input()))
steps = [0]*N
for a in A:
    steps[a-1] = 1
cnt = []
for n in range(N):
    if n == 0:
        if steps[n]==0:
            cnt.append(1)
        elif steps[n]==1:
            cnt.append(0)
    elif n == 1:
        if steps[n]==0:
            cnt.append(cnt[n-1]+1)
        elif steps[n]==1:
            cnt.append(0)
    elif steps[n] == 0:
        cnt.append((cnt[n-2]+cnt[n-1])%mod)
    elif steps[n] == 1:
        cnt.append(0)
print(cnt[-1])
x = input()
sum = 0
for i in range(x+1):
    if i % 3 or i % 5:
        pass
    else:
        sum += i
print(sum)

### FIXED CODE ###

x = int(input())
sum = 0
for i in range(x+1):
    if i % 3 == 0 or i % 5 == 0:
        pass
    else:
        sum += i
print(sum)
import sys
n = sys.stdin.readline()
if n = 'ABC':
  print('ARC')
else:
  print('ABC')

### FIXED CODE ###

import sys
n = sys.stdin.readline().strip()
if n == 'ABC':
  print('ARC')
else:
  print('ABC')
import sys
from functools import reduce
from math import gcd


def main():
    n, x = list(map(int, input().split()))
    values = list(map(int, input().split()))
    values.append(x)
    values.sort()
    v = [values[i + 1] - values[i] for i in range(len(values) - 1)]
    res = v[0]
    print(reduce(gcd, v[1:], v[0]))


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from functools import reduce
from fractions import gcd


def main():
    n, x = list(map(int, input().split()))
    values = list(map(int, input().split()))
    values.append(x)
    values.sort()
    v = [values[i + 1] - values[i] for i in range(len(values) - 1)]
    res = v[0]
    print(reduce(gcd, v[1:], v[0]))


if __name__ == "__main__":
    main()
for _ in range(int(input())):
    n = int(input())
    d = ['z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
    a = ''
    f = 0
    if n % 26 == 0:
        f = 1
    while n > f:
        a = d[n % 26] + a
        n //= 26
    print(a)

### FIXED CODE ###

n = int(input())
d = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
a = ''
while n:
  n -= 1
  a = d[n % 26] + a
  n //= 26
print(a)
from collections import defaultdict

n, k = map(int, input().split())
al = [int(i) for i in input().split()]

# dictionary で種類と数値をとっておく
d = defaultdict(int)
for a in al:
  d[a] += 1

# 種類が少ないものから色を変えていくと最小の変えなければいけないボールの数がわかる
ans = 0
if d.keys() > k:
  # 色を塗り替えないといけないので数えなければ…
  v = d.values()
  v.sort()
  ans = sum(v[:d.keys() - k])
print(ans)

### FIXED CODE ###

from collections import defaultdict

n, k = map(int, input().split())
al = [int(i) for i in input().split()]

# dictionary で種類と数値をとっておく
d = defaultdict(int)
for a in al:
  d[a] += 1

# 種類が少ないものから色を変えていくと最小の変えなければいけないボールの数がわかる
ans = 0
if len(d.keys()) > k:
  # 色を塗り替えないといけないので数えなければ…
  v = list(d.values())
  v.sort()
  ans = sum(v[:len(d.keys()) - k])
print(ans)
A, B = map(int, input().split())

def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    return gcd(a, b%a)

primes = []
for i in range(2, 10**3+10):
    if all(i%p for p in primes):
        primes.append(i)

g = gcd(A, B)
l = [0]*(g+1)
for p in primes:
    while g%p == 0:
        l[p] = 1
        g //= p
        if g == 1:
            break
    if g == 1:
        break

print(sum(l)+1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)

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

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a%b)

g = gcd(A, B)
count = 0
for i in range(2, 10**6+3):
    if g%i == 0:
        count += 1
    while g%i == 0:
        g //= i
if g != 1:
    count += 1

print(count+1)
A,B = map(float,input().split())
print(int(A*(B*100)/100)


### FIXED CODE ###

import decimal
A,B = input().split()
A = decimal.Decimal(A)
B = decimal.Decimal(B)
print(int(A*B))
l,r,d=map(int,input.split())
print((l-r+1)//d)


### FIXED CODE ###

l,r,d = map(int,input().split())
print(r//d - (l-1)//d)
import numpy as np
N = (int(i) for i in input().split())
b = [int(i) for i in input().split()]]
i=np.argsort(b)
print(i+1)

### FIXED CODE ###

import numpy as np
N = int(input())
b = [int(i) for i in input().split()]
s=np.argsort(b)

for i in range(N):
    print(s[i]+1, end=" ")
mod = 10**9 + 7
max = 10**5+10
fac, finv, inv = [0]*max, [0]*max, [0]*max

def comInit(max):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( n<0 | k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

#############

a = sorted(a)

mul = [0]* n
mul[k-1] = 1
for i in range(k, n):
    mul[i] = com(i, k-1)

ans = 0
for i in range(n):
    ans += (a[i] * mul[i]) - (a[i] * mul[ -1*(i+1)]) % mod
    ans = ans % mod

print(ans)

### FIXED CODE ###

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

#############

mod = 10**9 + 7
max = 10**5+10
fac, finv, inv = [0]*max, [0]*max, [0]*max

def comInit(max):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( n<0 | k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

#############

a = sorted(a)

mul = [0]* n
mul[k-1] = 1
for i in range(k, n):
    mul[i] = com(i, k-1)

ans = 0
for i in range(n):
    ans += (a[i] * mul[i]) - (a[i] * mul[ -1*(i+1)]) % mod
    ans = ans % mod

print(ans)
a,b=map(int,input().split())

print(int(a*b))

### FIXED CODE ###

a,b = map(float,input().split())

a = int(a)
b = int(round(float(b) * 100))

print(a*b//100)
N = int(input())
a = list(map(int, input().split()))

def sort_reverse(n):
    n.sort(reverse=True)
    return n

N_Even = list(range(0, N+1, 2))
N_Odd = list(range(1, N+1, 2))
a1 = sort_reverse(a)
sum1 = 0
sum2 = 0

for i in N_Even:
    sum1 += a1[i]
for j in N_Odd:
    sum2 += a1[j]

print(sum1 - sum2)

### FIXED CODE ###

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

def sort_reverse(n):
    n.sort(reverse=True)
    return n

N_Even = list(range(0, N, 2))
N_Odd = list(range(1, N, 2))
a1 = sort_reverse(a)
sum1 = 0
sum2 = 0

for i in N_Even:
    sum1 += a1[i]
for j in N_Odd:
    sum2 += a1[j]

print(sum1 - sum2)
if M <= N:
    print(0)
else:
    X.sort()
    L = []
    for i in range(M-1):
        L.append(X[i+1] - X[i])
    L.sort(reverse=True)
    print(X[-1]-X[0]-sum(L[:N-1]))

### FIXED CODE ###

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

if M <= N:
    print(0)
else:
    X.sort()
    L = []
    for i in range(M-1):
        L.append(X[i+1] - X[i])
    L.sort(reverse=True)
    print(X[-1]-X[0]-sum(L[:N-1]))