Harryxun/stf_run huggingface dataset:
def gcd(a, b):
    r = a % b
    if 0 == r:
        return b
    return gcd(b, r)


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


def lcm_arr(arr):
    ans = arr[0]
    for i in range(1, n):
        ans = lcm(ans, arr[i])
    return ans


n = int(input())
ans = lcm_arr([int(input()) for _ in range(n)])
print(min(ans, 10 ** 18))


### FIXED CODE ###


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


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


def lcm_arr(arr):
    ans = arr[0]
    for i in range(1, n):
        ans = lcm(ans, arr[i])
    return ans


n = int(input())
ans = lcm_arr([int(input()) for _ in range(n)])
print(min(ans, 10 ** 18))
n,k = list(map(int,input().split()))
a=[]
d=[]
c=0
for i in range(n-1):
    d+=[int(input())]
    a+=list(map(int,input().split()))
    
for i in range(1,n+1):
    if i not in a:
        c+=1
print(c)

### FIXED CODE ###

n,k = list(map(int,input().split()))
a=[]
d=[]
c=0
for i in range(k):
    d+=[int(input())]
    a+=list(map(int,input().split()))
    
for i in range(1,n+1):
    if i in a:
        continue
    else:
        c+=1
print(c)
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
p_max = max(p)
diff = [0]
#リストに含まれるものは飛ばす
for i in range(1, 101):
    if X - i not in p:
        print(X -1)
        break
    if X + i not in p:
        print(X + i)
        break

### FIXED CODE ###

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

p = set(p)
for i in range(200):
    if X - i not in p:
        print(X - i)
        break
    if X + i not in p:
        print(X + i)
        break
da = list(map(int,input(),split()))
a = 0
k = 0
for i in range(3):
  if  da[i] == 5:
    a += 1
  elif da[i] == 7:
    k += 1

if a == 2 and k == 1:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

da = list(map(int,input().split()))
a = 0
k = 0
for i in range(3):
  if  da[i] == 5:
    a += 1
  elif da[i] == 7:
    k += 1
 
if a == 2 and k == 1:
  print("YES")
else:
  print("NO")
N = int(input())
b = list(map(int, input().split()))
a = [b[0]]
if N == 2:
  a.append[b[0]]
elif N > 2:
  for i in range(N-2):
    a.append(min(b[i], b[i+1]))
  a.append(b[N-2])

print(sum(a))

### FIXED CODE ###

N = int(input())
b = list(map(int, input().split()))
a = [b[0]]
if N == 2:
  print(2*a[0])
elif N > 2:
  for i in range(N-2):
    a.append(min(b[i], b[i+1]))
  a.append(b[N-2])
  print(sum(a))
def main():
    n, q, *abpx = map(int, open(0).read().split())

    g = [[] for _ in range(n + 1)]
    for u, v in zip(*[iter(abpx[:2 * (n - 1)])] * 2):
        g[u].append(v)
        g[v].append(u)

    f = [0 for _ in range(n + 1)]

    for p, x in zip(*[iter(abpx[2 * (n - 1):])] * 2):
        f[p] += x

    k = [0 for _ in range(n + 1)]
    vis = [False for _ in range(n + 1)]

    def c(n, p):
        if vis[n]:
            return
        vis[n] = True
        w = f[n] + p
        k[n] = w
        ch = g[n]
        for x in ch:
            c(x, w)

    c(1, 0)
    ans = ' '.join(map(str, k[1:]))
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def c(i, p, f, g, k, vis):
    if vis[i]:
        return
    vis[i] = True
    w = f[i] + p
    k[i] = w
    ch = g[i]
    for x in ch:
        c(x, w, f, g, k, vis)


def main():
    import sys
    sys.setrecursionlimit(300000)
    n, q, *abpx = map(int, sys.stdin.read().split())

    g = [[] for _ in range(n + 1)]
    for u, v in zip(*[iter(abpx[:2 * (n - 1)])] * 2):
        g[u].append(v)
        g[v].append(u)

    f = [0 for _ in range(n + 1)]

    for p, x in zip(*[iter(abpx[2 * (n - 1):])] * 2):
        f[p] += x

    k = [0 for _ in range(n + 1)]
    vis = [False for _ in range(n + 1)]

    c(1, 0, f, g, k, vis)
    ans = ' '.join(map(str, k[1:]))
    print(ans)


if __name__ == '__main__':
    main()
n = input()
S = input()
c = 0
for i in range(len(S)):
  if S[i] == 'A' and S[i + 1] == 'B' and S[i+2] == 'C':
    c += 1
print(c)

### FIXED CODE ###

n = input()
S = input()
c = 0
for i in range(len(S)-2):
  if S[i] == 'A' and S[i + 1] == 'B' and S[i+2] == 'C':
    c += 1
print(c)
a,b=map(int,input(),split())
print(max(a+b,a-b,a*b))

### FIXED CODE ###

a,b=map(int,input().split())
print(max(a+b,a-b,a*b))
n=int(input())
dp=[1]*10**7
ans=1
for num in range(2,n+1):
  for i in range(num,10**7,num):
    dp[i]+=1
  ans+=dp[num]*num
print(ans)

### FIXED CODE ###

n=int(input())
dp=[1]*((10**7)+100)
ans=1
for num in range(2,n+1):
  for i in range(num,(10**7)+1,num):
    dp[i]+=1
  ans+=dp[num]*num
print(ans)
N = int(input())
T, A= map(int, input().split())
H = list(map(int, input().split()))
dH =[0]
for i in range(N):
    dH[i] = A + 0.006 * H[i]
min_dH = min(dH)
print(dH.index(min_dH) + 1)

### FIXED CODE ###

N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))
k = []
for i in H:
    k.append(abs(A-(T-i*0.006)))
print(k.index(min(k))+1)
n, m = [int(_) for _ in input().split()]
c = []
flag = True
g = [-1 for _ in range(n)]
for i in range(m):
    l, r, d = [int(_) for _ in input().split()]
    l -= 1
    r -= 1
    if g[l] != -1 and g[r] != -1 and g[l] == g[r]:
        c_tmp = [_[0] for _ in c[g[l]]]
        if c[g[l]][c_tmp.index(r)][1] - c[g[l]][c_tmp.index(l)][1] != d:
            flag = False
            break
    elif g[l] != -1 and g[r] != -1:
        c_tmp = [_[0] for _ in c[g[l]]]
        l_pos = c[g[l]][c_tmp.index(l)][1]

        c_tmp = [_[0] for _ in c[g[r]]]
        r_pos = c[g[r]][c_tmp.index(r)][1]

        for j in range(len(c[g[r]])):
            c[g[r]][j][1] += l_pos + d - r_pos
        c[g[l]].extend(c[g[r]])
        del c[g[r]]
    elif g[l] != -1:
        c_tmp = [_[0] for _ in c[g[l]]]
        l_pos = c[g[l]][c_tmp.index(l)][1]
        c[g[l]].append([r, l_pos+d])
        g[r] = g[l]
    elif g[r] != -1:
        c_tmp = [_[0] for _ in c[g[r]]]
        r_pos = c[g[r]][c_tmp.index(r)][1]
        c[g[r]].append([l, r_pos-d])
        g[l] = g[r]
    else:
        c.append([[l, 0], [r, d]])
        g[l] = max(g)+1
        g[r] = g[l]
if flag:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n, m = [int(_) for _ in input().split()]
c = []
flag = True
g = [[-1, -1] for _ in range(n)]
g_num = 0
for i in range(m):
    l, r, d = [int(_) for _ in input().split()]
    l -= 1
    r -= 1
    if g[l][0] != -1 and g[r][0] != -1 and g[l][0] == g[r][0]:
        if c[g[l][0]][g[r][1]][1] - c[g[l][0]][g[l][1]][1] != d:
            flag = False
            break
    elif g[l][0] != -1 and g[r][0] != -1:
        l_pos = c[g[l][0]][g[l][1]][1]
        r_pos = c[g[r][0]][g[r][1]][1]
        if r_pos > l_pos+d:
            for j in c[g[l][0]]:
                j[1] += r_pos - d - l_pos
                if j[1] > 10**9:
                    flag = False
                    break
                g[j[0]][1] += g[c[g[r][0]][-1][0]][1] + 1
            c[g[r][0]].extend(c[g[l][0]])
            for j in c[g[l][0]]:
                g[j[0]][0] = g[r][0]

        else:
            for j in c[g[r][0]]:
                j[1] += l_pos + d - r_pos
                if j[1] > 10**9:
                    flag = False
                    break
                g[j[0]][1] += g[c[g[l][0]][-1][0]][1] + 1
            c[g[l][0]].extend(c[g[r][0]])
            for j in c[g[r][0]]:
                g[j[0]][0] = g[l][0]

    elif g[l][0] != -1:
        l_pos = c[g[l][0]][g[l][1]][1]
        c[g[l][0]].append([r, l_pos+d])
        g[r][0] = g[l][0]
        g[r][1] = g[c[g[l][0]][-2][0]][1]+1
    elif g[r][0] != -1:
        r_pos = c[g[r][0]][g[r][1]][1]
        c[g[r][0]].append([l, r_pos-d])
        g[l][0] = g[r][0]
        g[l][1] = g[c[g[r][0]][-2][0]][1]+1
    else:
        c.append([[l, 0], [r, d]])
        g[l][0] = g_num
        g[r][0] = g[l][0]
        g[l][1] = 0
        g[r][1] = 1
        g_num += 1
    if not flag:
        break
if flag:
    print("Yes")
else:
    print("No")
# AOJ 0519: Worst Reporter
# Python3 2018.6.20 bal4u

# トポロジーソート V:総ノード数, to[][]:隣接リスト
def topological_sort(V, to):
	cnt = [0]*V
	for i in range(V):
		for j in to[i]: cnt[j] += 1
	Q = []
	for i in range(V):
	   if cnt[i] == 0: Q.append(i)
	f = 0
	while len(Q) > 0:
		f |= len(Q) > 1
		i = Q[0]
		del Q[0]
		print(i+1)  # ノードの表示
		for k in to[i]:
			cnt[k] -= 1
			if cnt[k] == 0:	Q.append(k)
	return f	

import fileinput
n = int(fileinput.input())
to = [[] for i in range(n)]
m = int(fileinput.input())
for i in range(m):
	a, b = list(map(int, fileinput.input().split()))
	to[a-1].append(b-1)
print(1 if topological_sort(n, to) else 0)



### FIXED CODE ###

# AOJ 0519: Worst Reporter
# Python3 2018.6.20 bal4u

# トポロジーソート V:総ノード数, to[][]:隣接リスト
def topological_sort(V, to):
	cnt = [0]*V
	for i in range(V):
		for j in to[i]: cnt[j] += 1
	Q = []
	for i in range(V):
	   if cnt[i] == 0: Q.append(i)
	f = 0
	while len(Q) > 0:
		f |= len(Q) > 1
		i = Q[0]
		del Q[0]
		print(i+1)  # ノードの表示
		for k in to[i]:
			cnt[k] -= 1
			if cnt[k] == 0:	Q.append(k)
	return f	

n = int(input())
to = [[] for i in range(n)]
m = int(input())
for i in range(m):
	a, b = list(map(int, input().split()))
	to[a-1].append(b-1)
print(1 if topological_sort(n, to) else 0)
from math import gcd

a,b,k = map(int,input().split())

g = gcd(a,b)

cnt = 0
for i in range(g,0,-1):
  if a%i == 0 and b%i == 0:
    # print('i is now ',i)
    cnt+=1
    if cnt == k:
      print(i)
      break


### FIXED CODE ###

# from math import gcd
def gcd(a,b):
    if b == 0:return a
    return gcd(b,a%b)

a,b,k = map(int,input().split())

g = gcd(a,b)

cnt = 0
for i in range(g,0,-1):
  if a%i == 0 and b%i == 0:
    # print('i is now ',i)
    cnt+=1
    if cnt == k:
      print(i)
      break
eval('print(('+input().replace(' ','-1)*(')+'-1))'

### FIXED CODE ###

a,b=map(lambda x:int(x)-1,input().split())
print(a*b)
N, A = map(int,input().split())
X = list(map(int,input().split()))
dp = [[[0 for i in range(N*A+1)] for j in range(N+1)] for k in range(N+1)]
dp[0][0][0] = 1
for i in range(1,N+1):
    x = X[i-1]
    for j in range(N):
        for k in range(N*M+1):
            if k < x:
                dp[i][j][k] += dp[i-1][j][k]
            elif j > i:
                dp[i][j][k] = 0
            else:
                dp[i][j][k] += dp[i-1][j][k] + dp[i-1][j-1][k-x]
for i in range(1,N+1):
    ans += dp[N][i][N*i]
print(ans)
                

### FIXED CODE ###

N, A = map(int,input().split())
X = list(map(int,input().split()))
dp = [[[0 for i in range(N*50+1)] for j in range(N+1)] for k in range(N+1)]
for i in range(N+1):
    dp[i][0][0] = 1
for i in range(1,N+1):
    x = X[i-1]
    for j in range(1,N+1):
        for k in range(N*50+1):
            if k < x:
                dp[i][j][k] = dp[i-1][j][k]
                
            elif j > i:
                dp[i][j][k] = 0
                
            else: 
                dp[i][j][k] += dp[i-1][j][k] + dp[i-1][j-1][k-x]
ans = 0
for i in range(1,N+1):
    ans += dp[N][i][A*i]
print(ans)
# -*- coding: utf-8 -*-

a, b = map(int, raw_input().split())
print "%d %d %f" %(a/b, a%b, (float)a/b)

### FIXED CODE ###

# -*- coding: utf-8 -*-

a, b = map(int, raw_input().split())
print "%d %d %f" %(a/b, a%b, float(a)/b)
N = int(input())
L = list(map(int, input().split()))
count = 0
count2 = 0
for i in range(0, N):
  if L[i]%2==0:
    count = count + 1
    if L[i]%3==0 or L[i]%5==0:
      count2 = count2 + 1

if count == count2:
  prin("APPROVED")
else:
  print("DENIED")


### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
count = 0
count2 = 0
for i in range(0, N):
  if L[i]%2==0:
    count = count + 1
    if L[i]%3==0 or L[i]%5==0:
      count2 = count2 + 1

if count == count2:
  print("APPROVED")
else:
  print("DENIED")
d,n=map(int,input().split())
a=[]
if d!=0:
    print(100**d*n)
else:
    for i in range(1,n**3):
        if i!=100:
            a.append(i)
    print(a[n-1])


### FIXED CODE ###

d,n=map(int,input().split())
a=[]
for i in range(1,2*n* 100**d):
    if i% 100**d==0 and i % 100**(d+1)!=0:
        a.append(i)
print(a[n-1])
n = list(int, input().split())
n.sort()
if n[0] == n[1] == 5 and n[2] == 7:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

n = list(map(int, input().split()))
n.sort()
if n[0] == n[1] == 5 and n[2] == 7:
  print("YES")
else:
  print("NO")
#標準入力
N = int(input())
D, X = list(map(int, input().split()))
A = []
for i in range(N):
    A.append(input())
    
B=0
for i in range(N):
    B += 1 + (D-1)//A[i]

    
Total = X + B

print(Total)



### FIXED CODE ###

N = int(input())
D, X = map(int, input().split())
A = []
for i in range(N):
    A.append(int(input()))
    
B=0
for i in range(N):
    B += 1 + (D-1)//A[i]

    
Total = X + B

print(Total)
N = int(input())
p = [int(input()) for i in range(N)]
print(sum() - max(p))

### FIXED CODE ###

N = int(input())
p = [int(input()) for i in range(N)]
print(sum(p) - max(p) // 2)
s = input()
s=sorted(s)
if s[0]==S[1] and s[2]==s[3]:	print("Yes")
else:							print("No")



### FIXED CODE ###

s = input()
s = sorted(s)
if s[0]==s[1] and s[1]!=s[2] and s[2]==s[3]:
	print("Yes")
else:
	print("No")
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if (cnt > 0) and (a[i]==(a[i-1]+1)):
        cnt += c[i]

    cnt += b[a[i]-1]
    
print(cnt)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if (cnt > 0) and (a[i]==(a[i-1]+1)):
        cnt += c[a[i-1]-1]

    cnt += b[a[i]-1]
    
print(cnt)
N=int(input())
A=list(map(int, input().split()))
p,S = 0,0
for i in range(N-1):
    ap = A.pop(0)
    AA = sum(A)
    aa = ap*AA
    a = aa%1000000007
    S += a
p = S%1000000007
print(p)

### FIXED CODE ###

S = input()
T = input()
lS = len(S)
lT = len(T)
C = []
for i in range(lS-lT+1):
    count = 0
    for j in range(lT):
        if S[i+j]!=T[j]:
            count += 1
    C.append(count)
print(min(C))
number = int(input())
list = map(int,input().split())
yon_num = 0
ni_num = 0
odd_num = 0
for num in list:
    if num%4 == 0:
        yon_num += 1
    elif num%2 == 0:
        ni_num +=1
    else:
        odd_num += 1

    if ni_num != 0:
        nibai = ni_num//2 + ni_num%2

if yon_num >= (odd_num + nibai  + yon_num) // 2 :
    print('Yes')
else:
    print('No')


### FIXED CODE ###

number = int(input())
list = map(int,input().split())
yon_num = 0
ni_num = 0
odd_num = 0
for num in list:
    if num%4 == 0:
        yon_num += 1
    elif num%2 == 0:
        ni_num +=1
    else:
        odd_num += 1

    if ni_num != 0:
        ni_num = ni_num//2 + ni_num%2

if yon_num >= (odd_num + ni_num  + yon_num) // 2 :
    print('Yes')
else:
    print('No')
def nabeatsu(n):
    if(n % 3 == 0):
        return True
    temp = n
    while(temp > 0):
        if(temp % 10 == 3):
            return True
        temp = temp // 10
    return False

x = int(input())
ans = []
for i in range(x):
    if(nabeatsu(i + 1)):
        ans.append(i + 1)
print((' '.join(ans)))


### FIXED CODE ###

def nabeatsu(n):
    if(n % 3 == 0):
        return True
    temp = n
    while(temp > 0):
        if(temp % 10 == 3):
            return True
        temp = temp // 10
    return False

x = int(input())
for i in range(x):
    if(nabeatsu(i + 1)):
        print(' ', end = '')
        print(i + 1, end = '')
print()
def euclid(a, b):
        if a < b:
            a, b = (b, a)
     
        while True:
            r = a % b
            if r == 0:
                break
            a, b = (b, r)
     
        return b
     
     
    if __name__ == '__main__':
        n, x = tuple(map(int, input().split()))
        points = [int(x) for x in input().split()]
        if not x in points:
            points.append(x)
     
        buf = [abs(points[i + 1] - points[i]) for i in range(len(points) - 1)]
        while len(buf) > 1:
            buf = [euclid(buf[i + 1], buf[i]) for i in range(len(buf) - 1)]
     
        print(buf[0])

### FIXED CODE ###

from functools import reduce

def euclid(a, b):
    if a < b:
        a, b = (b, a)

    while True:
        r = a % b
        if r == 0:
            break
        a, b = (b, r)

    return b


if __name__ == '__main__':
    n, x = tuple(map(int, input().split()))
    points = [int(x) for x in input().split()]

    buf = [abs(p - x) for p in points]
    print(reduce(lambda a,b: euclid(a, b), buf))
#!/usr/bin python3
# -*- coding: utf-8 -*-

k = int(input())
if k%2==0:
    print(-1)
else:
    ret = len(str(k))-1
    x = int('7'*(len(str(k))-1))
    res = x%k
    while res != 0:
        res = (res * 10 + 7) % k
        ret += 1
    print(ret)


### FIXED CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

k = int(input())
if k%2==0 or k%5==0:
    print(-1)
else:
    ret = 1
    res = 7%k
    while res != 0:
        res = (res * 10 + 7) % k
        ret += 1
    print(ret)
N, Q = map(int, input().split())
tree = [[] for i in range(N+1)]
scores = [0 for i in range(N+1)]

def dfs(pre, p):
    for child in tree[p]:
        if child == pre: continue
        scores[child] += scores[p]
        dfs(p, child)

def main():
    for _ in range(N-1):
        a, b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)

    for _ in range(Q):
        p, x = map(int, input().split())
        scores[p] += x
    dfs(0, 1)
    print(' '.join(map(str, scores[1:])))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from heapq import *
sys.setrecursionlimit(10**8)

input = sys.stdin.readline

tree = [[] for _ in range(200001)]
res = [0]*200001

def dfs(p, pre):
    for child in tree[p]:
        if child == pre: continue
        res[child] += res[p]
        dfs(child, p)

def main():
    """ main """
    N, Q = map(int, input().split())
    for _ in range(N-1):
        a,b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)
    for _ in range(Q):
        p,x = map(int, input().split())
        res[p] += x
    dfs(1, 0)

    print(*res[1:N+1])

if __name__ == '__main__':
    main()
n,k=map(int,input().split())
s=input()
t=s.pop(k-1)
s.insert(k-1,t.lower())
print(s)

### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
t=s.pop(k-1)
s.insert(k-1,t.lower())
print("".join(s))
n=stirng(input())
ans="No"
if(n[0]=='7'||n[1]=='7'||n[2]=='7')
	ans="Yes"
print(ans)

### FIXED CODE ###

n=input()
ans="No"
if (n[0]=='7' or n[1]=='7' or n[2]=='7'):
	ans="Yes"
print(ans)
v = []
    v = str(inp).splitlines()
    dif_max = -200000

    for i in range(len(v) ):
        v[i] = int(v[i])

    for i in range(len(v) - 1):
        for j in range(i + 1, len(v), 1):
            dif = v[j] - v[i]
            dif_max = dif if dif_max < dif else dif_max
    print("{}".format(dif_max))

### FIXED CODE ###

cnt = int(input())
dif_max = -1000000000
v_min = 1000000000

for i in range(cnt):
    buf = int(input())
    if i > 0:
        dif_max = dif_max if buf - v_min < dif_max else buf - v_min
    v_min = buf if buf < v_min else v_min
print(dif_max)
k,n=map(int, input().strip().split())
a=list(map(int, input().strip().split()))
a.append(a[0]+k)

ans=0
for i in range(n):
 ans=max(max, a[i+1]-a[i])
print(k-ans)

### FIXED CODE ###

k,n=map(int, input().strip().split())
a=list(map(int, input().strip().split()))
a.append(a[0]+k)

v=0
for i in range(n): v=max(v,a[i+1]-a[i])
print(k-v)
s=input()
n=len(s)
if s[0]==s[-1] and s[0]==s[int((n-1)/2-1)] and s[int((n+3)/2-1)]==s[-1] and s[1]==s[-2] and s[2]==s[-3] and s[int((n+3)/2)]==s[-2]:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

s=input()
n=len(s)
k=n//2
a=s[:k]
b=s[-k:]
if s==s[::-1] and a==a[::-1] and b==b[::-1]:
    print('Yes')
else:
    print('No')
import datetime

S = input()
ans = "TBD"
datetime.datetime.strptime(S, '%Y/%M/%d')
tbd=datetime(2019/4/30)
if S <= tbd:
    ans="Heisei"
print("ans")


### FIXED CODE ###

y,m,d = map(int, input().split("/"))
if y > 2018 and m > 4 :
    print("TBD")
else:
    print("Heisei")
# B - Traveling AtCoDeer Problem
N = int(input())
a = list(map(int, input().split()))
A = set(a)
A1 = sorted(A)
count = 0
for i in range(N-1) :
    count += A1[i+1]-A1[i]

print(count)

### FIXED CODE ###

# B - Traveling AtCoDeer Problem
N = int(input())
a = list(map(int, input().split()))
A = set(a)
A1 = sorted(A)
count = 0
for i in range(len(A)-1) :
    count += A1[i+1]-A1[i]

print(count)
# -*- coding: utf-8 -*-


N,K=map(int, input().split())
H=list(map(int, input().split()))
G=[0]
G.extend(H[:])

dp=[[0]*(N+1) for i in range(N-K+1)]
dp[1][1]=G[1]
for jtemp in range(N-1):
    j=jtemp+2
    dp[1][j]=G[j]#min(dp[1][j-1],G[j])
for itemp in range(N-K-1):
    i=itemp+2
    for jtemp in range(N-(i-1)):
        j=jtemp+i
        temp=int(N*1e9)
        
        for ktemp in range(j-(i-1)):
            k=ktemp+i-1
            val=G[j]-G[k]
            if val<0:
                val=0
            if temp>dp[i-1][k]+val:
                temp=dp[i-1][k]+val
        dp[i][j]=temp
temp=dp[N-K][-1]
for jtemp in range(N):
    j=jtemp+1
    if temp>dp[N-K][j] and dp[N-K][j]!=0:
        temp=dp[N-K][j]
print(temp)

### FIXED CODE ###

# -*- coding: utf-8 -*-


N,K=map(int, input().split())
H=list(map(int, input().split()))
G=[0]
G.extend(H[:])

dp=[[0]*(N+1) for i in range(N-K+1)]


tempa=0
if K<N-1:
    for jtemp in range(N):
        j=jtemp+1
        dp[1][j]=G[j]#min(dp[1][j-1],G[j])
    for itemp in range(N-K-1):
        i=itemp+2
        for jtemp in range(N-(i-1)):
            j=jtemp+i
            temp=int(N*1e9)
            
            for ktemp in range(j-(i-1)):
                k=ktemp+i-1
                val=G[j]-G[k]
                if val<0:
                    val=0
                if temp>dp[i-1][k]+val:
                    temp=dp[i-1][k]+val
            dp[i][j]=temp
    tempa=dp[N-K][-1]
    for jtemp in range(N):
        j=jtemp+1
        if tempa>dp[N-K][j] and dp[N-K][j]!=0:
            tempa=dp[N-K][j]
elif N-K==1:
    tempa=min(H[:])
else:
    tempa=0
print(tempa)
N, M = map(int, input().split())
a = [0] * 1000
b = [0] * 1000
c = [0] * 1000
for i in range(M):
    a[i], b[i], c[i] = map(int, input().split())
    c[i] = -c[i]
    
INF = 10 ** 10
dist = [INF] * 1000

dist[0] = 0

for loop in range(N-1):
    for i in range(M):
        if dist[a[i]-1] == INF:
            continue
        if dist[b[i]-1] > dist[a[i]-1] + c[i]:
            dist[b[i]-1] = dist[a[i]-1] + c[i]

ans = dist[N-1]

nega = [0] * 1000

for loop in range(N):
    for i in range(M):
        if dist[a[i]-1] == INF:
            continue
        if dist[b[i]-1] > dist[a[i]-1] + c[i]:
            dist[b[i]-1] = dist[a[i]-1] + c[i]
            nega[b[i]-1] = 1
        if nega[a[i]-1] == 1:
            nega[b[i]-1] = 1

if nega[N-1]:
    print('inf')
else:
    print(-ans)

### FIXED CODE ###

N, M = map(int, input().split())
a = [0] * M
b = [0] * M
c = [0] * M
for i in range(M):
    a[i], b[i], c[i] = map(int, input().split())
    c[i] = -c[i]
    
INF = 10 ** 13
dist = [INF] * N

dist[0] = 0

for loop in range(N-1):
    for i in range(M):
        if dist[a[i]-1] == INF:
            continue
        if dist[b[i]-1] > dist[a[i]-1] + c[i]:
            dist[b[i]-1] = dist[a[i]-1] + c[i]

ans = dist[N-1]

nega = [0] * N

for loop in range(N):
    for i in range(M):
        if dist[a[i]-1] == INF:
            continue
        if dist[b[i]-1] > dist[a[i]-1] + c[i]:
            dist[b[i]-1] = dist[a[i]-1] + c[i]
            nega[b[i]-1] = 1
        if nega[a[i]-1] == 1:
            nega[b[i]-1] = 1

if nega[N-1]:
    print('inf')
else:
    print(-ans)
X=int(input())
n_max=0
for i in range(int(X**0.5)+1):
  if(X==1):
    n_max=1
    break
  else:
    for j in range(X):
      if((i+1)**(j+1)>X):
        #print('i='+str(i+1)+' j='+str(j))
        #print((i+1)**j)
        n_max=max(n_max,(i+1)**j)
        break
print(n_max)

### FIXED CODE ###

a,b,c,d=map(int,input().split())
if (abs(a-c) <=d or (abs(a-b)<=d and abs(b-c)<=d)):
  print('Yes')
else:print('No')