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

from functools import reduce
n = int(input())
a = [int(x) for x in input().split()]

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

if x > 10**18:
    print("-1")
else:
    print(x)

### FIXED CODE ###

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


ans = 1
a.sort()

for i in range(n):
    ans = ans * a[i]
    if a[i] == 0:
        print("0")
        exit(0)
    if ans > 10 ** 18:
        print("-1")
        exit(0)

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

n,m = map(int,input().split())
cards = list(map(int,input().split()))
cards.sort()
actions = []
#print()
#print(cards)
for i in range(m):
    l,r  = map(int,input().split())
    actions.append([r,l])
actions.sort(reverse=True)
for i in range(m):
    minnum = min(cards)
    if actions[i][0] <= minnum:
        break
    else:
        for j in range(actions[i][1]):
            #print(cards[j])
            if cards[j] <= actions[i][0]:
                cards[j] = actions[i][0]
            else:
                break
    cards.sort()
    #print(cards)
print(sum(cards))

### FIXED CODE ###

import sys
input = sys.stdin.readline
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

minA = A[0]
Query = []
for _ in range(m):
    b,c = map(int,input().split())
    if c > minA:
        Query.append([b,c])
Query = sorted(Query, key=lambda x:(x[1], x[0]), reverse=True)

ans = 0
index = 0
for b,c in Query:
    if index >= n:
        break
    #print("----")
    cnt = 0
    Flag = True
    while Flag:
        #print(A,b,c,index)
        if A[index] < c:
            A[index] = c
            cnt += 1
            index += 1
            if (cnt >= b) or (index >= n):
                Flag = False
        else:
            Flag = False
    '''
    #A.sort()
    if A[0] >= c:
        break
    else:
        index = min(bisect.bisect_left(A,c),b)
        if index > len(A):
            ans += c * len(A)
            break
        else:
            ans += c * index
            A = A[index:]
    print(A)
    '''
print(sum(A))
### BUGGY CODE ###

N = int(input())
S = list(input())

res = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if j - i == k - j:
                continue
            if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
                res += 1

print(res)


### FIXED CODE ###

N = int(input())
S = list(input())

r = len([s for s in S if s == "R"])
g = len([s for s in S if s == "G"])
b = len([s for s in S if s == "B"])

res = r * g * b

for i in range(N-2):
    for j in range(i+1, N-1):
        k = j + (j - i)
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            res -= 1

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

L,R = map(int,input().split())

if L-R > 672:
    print(0)
else:
    minMod = 100000000
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp = (i*j)%2019
            if minMod > tmp:
                minMod = tmp
    print(minMod)

### FIXED CODE ###

L,R = map(int,input().split())

if R-L > 672:
    print(0)
else:
    minMod = 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp = (i*j)%2019
            if tmp == 0:
                minMod = 0
                break
            minMod = min(tmp,minMod)
    print(minMod)
### BUGGY CODE ###

import math

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

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


ANS=0

if B>A:
    (A,B)=(B,A)

ran=K//A

for i in range(min(ran,N)+1):
    q, mod = divmod(K-(A*i), B)
    if mod==0 and q<=N:
        ANS = (ANS+(Combi(N,i)*Combi(N,q)))%998244353

print(ANS)

### FIXED CODE ###

N,A,B,K=map(int,input().split())
mod=998244353

INV=[None]*(N+1)
for i in range(1,N+1):
    INV[i]=pow(i,mod-2,mod)

Combi=[None]*(N+1)
Combi[0]=1
Combi[1]=N
for i in range(2,N//2+2):
    Combi[i]=Combi[i-1]*(N-i+1)*INV[i] %mod
for i in range(N//2+2,N+1):
    Combi[i]=Combi[N-i]


ANS=0

if B>A:
    (A,B)=(B,A)

ran=K//A

for i in range(min(ran,N)+1):
    q, r = divmod(K-(A*i), B)
    if r==0 and q<=N:
        ANS = (ANS+(Combi[i]*Combi[q])%mod)%mod

print(ANS)
### BUGGY CODE ###

from operator import mul
from functools import reduce

n = int(input())
a = list(map(int, input().split()))
ans = reduce(mul, a)
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

from operator import mul
from functools import reduce

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

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

for i in range(len(a)):
    cnt *= a[i]
    if cnt > 10 ** 18:
        print(-1)
        exit()
print(cnt)
### BUGGY CODE ###

N = int(input())
list_b = list(map(int, input().split()))
aaa = [[1, 1], [1, 2]]
ans = [[1, 1], [1, 2]]
for i in range(2,N):
  j = []
  f = []
  for d in range(len(aaa)):
    s = []
    t = []
    for k in range(i+1):
      a = aaa[d].copy()
      b = ans[d].copy()
      a.insert(k, k+1)
      b.append(k+1)
      s.append(a)
      t.append(b)
    j += s
    f += t
  aaa = j
  ans = f

if list_b in aaa:
  index = aaa.index(list_b)
  anser = ans[index]
  for i in range(N):
    print(anser[i])
else:
  print('-1')

### FIXED CODE ###

N = int(input())
list_b = list(map(int, input().split()))
ans = [0 for i in range(N)]

finish = False

for i in range(N-1, -1, -1):
  mx = -1
  for k in range(i+1):
    if list_b[k] == k+1:
      mx = max(mx, k+1)
  if mx == -1:
    finish = True
    break
  else:
    ans[i] = mx
    for j in range(mx-1, i):
      list_b[j] = list_b[j+1]
    
if not finish:
    for i in range(N):
        print(ans[i])
else:
    print(-1)
### BUGGY CODE ###

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

for i in range(0,int(n)):
  if(b[i] in b[i+1:]):
    print("NO")
    exit()
print("YES")


### FIXED CODE ###

n = input()
a = input().split()
b = [int(i) for i in a]
 
b.sort()

for i in range(0,int(n)-1):
  if(b[i] == b[i+1]):
    print("NO")
    exit()
print("YES")
### BUGGY CODE ###

# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
from itertools import combinations
def run():
    N = int(input())
    A = list(map(int, sysread().split()))

    A = [(idx, val) for idx, val in enumerate(A, 1) if val < N]
    ret = 0
    for (i,Ai), (j,Aj) in combinations(A, 2):
        if abs(i-j) == Ai+Aj:
            ret += 1

    print(ret)

if __name__ == "__main__":
    run()

### FIXED CODE ###

# coding: utf-8
import sys
sysread = sys.stdin.readline

def run():
    N = int(input())
    A = list(map(int, sysread().split()))


    A = [(idx, val) for idx, val in enumerate(A, 1) if val < N]

    ret = 0
    store = [0] * N
    for idx, val in A:
        if idx - val > 0:
            ret += store[idx - val]
        try:
            store[idx + val] += 1
        except:
            continue
    print(ret)

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

n, x=map(int, input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
  while a[i]+a[i+1]>x:
    a[i+1]-=1
    ans+=1
print(ans) 

### FIXED CODE ###

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

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


for i in range(N):
    price = 0
    now = 0
    cnt = 0
    while True:
        if (cnt == i):
            cnt += 1
            continue
        if (cnt == N):
            price += abs(now)
            break
        price += abs(A[cnt] - now)
        now = A[cnt]
        cnt += 1

    print(price)


### FIXED CODE ###

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

all_price = 0
now = 0
for i in range(N + 1):
    if (i == N):
        all_price += abs(A[i - 1])
        break
    all_price += abs(A[i] - now)
    now = A[i]


for i in range(N):
    if (i == 0):
        print(all_price + abs(A[i + 1] - 0) -
              (abs(A[i] - 0) + abs(A[i + 1] - A[i])))

    elif (i == N - 1):
        print(all_price + abs(A[i - 1] - 0) -
              (abs(A[i] - A[i - 1]) + abs(abs(A[i] - 0))))

    else:
        print(all_price + abs(A[i - 1] - A[i + 1]) -
              (abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1])))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N = ii()
ans = 0
for i in range(1, N+1):
    ans += i * len(make_divisors(i))

print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
ans = 0
for i in range(1, N+1):
    ans += (i * (N//i) + i) * (N//i) // 2

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

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, T, *AB = map(int, read().split())
    D = [(a, b) for a, b in zip(*[iter(AB)] * 2)]

    D.sort()

    dp = [0] * T
    ans = 0

    for i in range(N - 1):
        for t in range(T - 1, -1, -1):
            if t - D[i][0] >= 0 and dp[t] < dp[t - D[i][0]] + D[i][1]:
                dp[t] = dp[t - D[i][0]] + D[i][1]
        if ans < dp[T - 1] + D[i + 1][1]:
            ans = dp[T - 1] + D[i + 1][1]

    print(ans)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, T, *AB = map(int, read().split())
    A = AB[::2]
    B = AB[1::2]

    dp1 = [[0] * T for _ in range(N + 1)]
    for i in range(N):
        for t in range(T):
            if 0 <= t - A[i]:
                dp1[i + 1][t] = dp1[i][t - A[i]] + B[i]
            if dp1[i + 1][t] < dp1[i][t]:
                dp1[i + 1][t] = dp1[i][t]

    dp2 = [[0] * T for _ in range(N + 1)]
    for i in range(N - 1, -1, -1):
        for t in range(T):
            if 0 <= t - A[i]:
                dp2[i][t] = dp2[i + 1][t - A[i]] + B[i]
            if dp2[i][t] < dp2[i + 1][t]:
                dp2[i][t] = dp2[i + 1][t]

    ans = 0
    for i in range(N):
        tmp = max(dp1[i][t] + dp2[i + 1][T - t - 1] for t in range(T)) + B[i]
        if ans < tmp:
            ans = tmp

    print(ans)
    return


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

n = int(input())

l = list(map(int,input().split()))

ans = 1
for i in range(n):
    ans *= l[i]

if ans > 10**18:
  ans = -1

print(ans)


### FIXED CODE ###

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

l.sort(reverse = True)
ans = l[-1]
for i in range(n-1):
    ans *= l[i]
    if ans > 10**18:
      ans = -1
      break
    elif ans == 0:
      ans = 0
      break

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

import numpy as np
def solve():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(K):
        br = np.zeros(N, dtype=np.int64)
        for ind, rux in enumerate(A):
            br[max(ind-rux,0)] += 1
            l = ind+rux+1
            if l < N:
                br[l] -= 1
        A = br.cumsum()

        #X = br.cumsum()
        #A = X[:-1]ボトルネックっぽい
        if br[0] == N and br[-1] == -N:
            print(*A)
            exit()

    print(*A)

if __name__ == "__main__":
    solve()


### FIXED CODE ###

import numpy as np
from numba import njit

@njit('i8,i8,i8[::1]',cache=True)
def solve(N,K,A):
    for i in range(K):
        br = np.zeros(N+1, dtype=np.int64)

        for ind, rux in enumerate(A):
            br[max(ind-rux,0)] += 1
            br[min(ind+rux+1,N)] -= 1
        A = br.cumsum()[:-1]

        if br[0] == N and br[-1] == -N:
            return A
    return A


if __name__ == "__main__":
    n,k = map(int, input().split())
    a = np.array(list(map(int, input().split())),dtype=np.int64)
    ans = solve(n,k,a)
    print(*ans)
### BUGGY CODE ###

N = int(input())
S = str(input()) 

r = S.count('R')
g = S.count('G')
b = S.count('B')
total = r * g * b

k = 0
count = 0
for i in range(N):
    for j in range(N):
        k = 2 * j - i
        if(i>=j or j >=k or i >=k): continue
        if(i==j or j==k or k==i or k<0 or k>=N): continue
        if(S[i] == S[j] or S[j] == S[k] or S[k] == S[i]): continue
        
        count += 1
        
print(total - count)

### FIXED CODE ###

N = int(input())
S = str(input()) 

r = S.count('R')
g = S.count('G')
b = S.count('B')
total = r * g * b

k = 0
count = 0
for i in range(N):
    for j in range(N):
        k = 2 * j - i
        if(i>=j or j >=k or i >=k): continue
        if(i==j or j==k or k==i or k<0 or k>=N): continue
        if(S[i] == S[j] or S[j] == S[k] or S[k] == S[i]): continue
        
        count += 1
        
print(total - count)
### BUGGY CODE ###

import collections
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=[]
m2=[0]
for i in range(n):
  m.append(a[i])
for i in range(n):
  m2.append((m2[-1]+m[i]))
for i in range(n+1):
  m2[i]-=i
  m2[i]%=k

ans=0
dict={}
for i in range(1,n+1):
  x=m2[i]
  if i<=k-1:
    dict[i-1]=m2[i-1]
  else:
    dict[i-1]=m2[i-1]
    del dict[i-k]
  d=collections.Counter(dict.values())
  ans+=d[x]
print(ans)

### FIXED CODE ###

import collections
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=[]
m2=[0]
for i in range(n):
  m.append(a[i])
for i in range(n):
  m2.append((m2[-1]+m[i]))
for i in range(n+1):
  m2[i]-=i
  m2[i]%=k

ans=0
dict=collections.defaultdict(int)
for i in range(1,n+1):
  x=m2[i]
  if i<=k-1:
    dict[m2[i-1]]+=1
  else:
    dict[m2[i-1]]+=1
    dict[m2[i-k]]-=1
  ans+=dict[x]
print(ans)
### BUGGY CODE ###

n,m = list(map(int, input().split()))
lsta = []
lstb = []

for i in range(m):
    a,b = list(map(int, input().split()))
    if a==1:
        lsta.append(b)
    if b==n:
        lstb.append(a)

for i in lsta:
    if i in lstb:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")


### FIXED CODE ###

n,m = list(map(int, input().split()))
lsta = [0 for i in range(n+1)]
lstb = [0 for i in range(n+1)]

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

for i in range(n+1):
    if lsta[i]==1 and lstb[i]==1:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
### BUGGY CODE ###

import bisect
import array
 
n, m = map(int, input().split())
a = map(int, input().split())
a = array.array("L", sorted(list(a)))
for _ in range(m):  # O(m*n)
    max_num = a.pop()  # O(1)
    index = bisect.bisect(a, max_num // 2)  # O(log n)
    a.insert(index, max_num // 2)  # O(n)
print(sum(a))

### FIXED CODE ###

class heap():
    def __init__(self, maxcom=True):
        if maxcom:
            self.compare = lambda x, y: x > y
        else:
            self.compare = lambda x, y: x < y

    def heappush(self, x, heap):
        heap.append(x)
        length = len(heap)
        pointer = length
        while True:
            if pointer == 1:
                break
            if self.compare(heap[pointer - 1], heap[(pointer >> 1) - 1]):
                heap[pointer - 1], heap[(pointer >> 1) - 1] = heap[(pointer >> 1) - 1], heap[pointer - 1]
                pointer = pointer >> 1
            else:
                break

    def heapreplace(self, function, heap):
        heap[0] = function(heap[0])
        pointer = 1
        length = len(heap)
        while True:
            if (pointer << 1) > length:
                break
            elif (pointer << 1) + 1 > length :
                if self.compare(heap[(pointer << 1) - 1], heap[pointer - 1]):
                    heap[(pointer << 1) - 1], heap[pointer - 1] = heap[pointer - 1], heap[(pointer << 1) - 1]
                else:
                    break
            else:
                if self.compare(heap[(pointer << 1) - 1], heap[pointer << 1]):
                    next_pointer = pointer << 1
                else:
                    next_pointer = (pointer << 1) + 1
                if self.compare(heap[next_pointer - 1], heap[pointer - 1]):
                    heap[next_pointer - 1], heap[pointer - 1] = heap[pointer - 1], heap[next_pointer - 1]
                    pointer=next_pointer
                else:
                    break


n, m = map(int, input().split())
a = map(int, input().split())
heapq = []
heapc=heap(True)
for i in a:
    heapc.heappush(i,heapq)
for _ in range(m):
    heapc.heapreplace(lambda x:x>>1,heapq)
print(sum(heapq))
### BUGGY CODE ###

import sys

n, m = map(int, input().split())
ed = [[] for _ in range(n)]
v = [None] * n
for _ in range(m):
	l, r, d = map(int, input().split())
	ed[l-1].append([r-1, d])
	ed[r-1].append([l-1, -d])

def dfs(start):
	global ed, v
	visited = [False] * n
	s = [start]
	v[start] = 0
	while s:
		label = s.pop()
		if visited[label] == False:
			#print(label)
			visited[label] = True
			for e in ed[label]:
				if v[e[0]] is None:
					v[e[0]] = v[label] + e[1]
					s.append(e[0])
				else:
					if v[e[0]] != v[label] + e[1]:
						print("No")
						sys.exit()
	return

for i in range(n):
	if v[i] is None:
		#print(i)
		dfs(i)

print("Yes")

### FIXED CODE ###

import sys

n, m = map(int, input().split())
ed = [[] for _ in range(n)]
v = [None] * n
for _ in range(m):
	l, r, d = map(int, input().split())
	ed[l-1].append([r-1, d])
	ed[r-1].append([l-1, -d])

visited = [False] * n

def dfs(start):
	global ed, v, visited
	s = [start]
	v[start] = 0
	while s:
		label = s.pop()
		if visited[label] == False:
			visited[label] = True
			for e in ed[label]:
				if v[e[0]] is None:
					v[e[0]] = v[label] + e[1]
					s.append(e[0])
				else:
					if v[e[0]] != v[label] + e[1]:
						print("No")
						sys.exit()
	return

for i in range(n):
	if v[i] is None:
		dfs(i)

print("Yes")
### BUGGY CODE ###

import itertools
import operator

N, K = map(int, input().split())
sushi = [tuple([i] + [int(x) for x in input().split()]) for i in range(N)]
sushi.sort(key=operator.itemgetter(2), reverse=True)

from collections import OrderedDict, deque, Counter
left = OrderedDict((x[0], x) for x in sushi)

base = 0
choosen = []
choosen_kind = set()
for x in sushi:
    i, t, _ = x
    if t not in choosen_kind:
        choosen.append(x)
        choosen_kind.add(t)
        del left[i]

choosen.sort(key=operator.itemgetter(2), reverse=True)
choosen = choosen[:K]
base = sum(d for _,_,d in choosen)
kinds = len(choosen)

tl = list(itertools.islice(left.values(), K))
fixed = tl[:K - len(choosen)]
cands = tl[K - len(choosen):]
base += sum(d for _,_,d in fixed)

score = base + kinds**2

if cands:
    comp = []
    while cands and cands[0][2] > choosen[-1][2]:
        base_n = base
        base_n -= choosen[-1][2]
        base_n += cands[0][2]
        kinds_n = kinds - 1
        
        score_n = base_n + kinds_n**2
        if score_n > score:
            choosen = choosen[:-1]
            fixed += cands[0]
            cands = cands[1:]
            base, kinds, score = base_n, kinds_n, score_n
        else:
            break
print(score)

### FIXED CODE ###

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

from itertools import islice
import operator

N, K = map(int, input().split())
sushi = [tuple([i] + [int(x) for x in input().split()]) for i in range(N)]
sushi.sort(key=operator.itemgetter(2), reverse=True)

from collections import OrderedDict, deque, Counter
left = OrderedDict((x[0], x) for x in sushi)

base = 0
choosen = [None] * N
choosen_kind = set()
ci = 0
for x in sushi:
    i, t, _ = x
    if t not in choosen_kind:
        choosen[ci] = x
        ci += 1
        choosen_kind.add(t)
        del left[i]

choosen = choosen[:min(ci, K)]
base = sum(d for _,_,d in choosen)
kinds = len(choosen)

cands = islice(left.values(), K)
fixed = islice(cands, K - len(choosen))
base += sum(d for _,_,d in fixed)

score = base + kinds**2

for cand in cands:
    if cand[2] <= choosen[-1][2]:
        break

    base_n = base
    base_n -= choosen[-1][2]
    base_n += cand[2]
    kinds_n = kinds - 1
    
    score_n = base_n + kinds_n**2
    if score_n > score:
        choosen.pop()
        base, kinds, score = base_n, kinds_n, score_n
    else:
        break

print(score)
### BUGGY CODE ###

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

for i in range(k):
  if a>=1:
    a-=1
  elif b>=1:
    b-=1
print(a,b)

### FIXED CODE ###

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

aa=a
bb=b
if a>=1:
  a-=k
  k-=aa
if b>=1 and k>0:
  b-=k
  k-=bb

if a<0:
  a=0
if b<0:
  b=0
print(a,b)
### BUGGY CODE ###

s = input()
K = int(input())
A =[]
b = len(s)
for i in range(b+1):
  for j in range(b+1):
    if j > i:
      A.append(s[i:j])
for i in range(b):
  A.append(s[i])
B = set(A)
B = list(B)
B = sorted(B)
print(B[K-1])

### FIXED CODE ###

s = input()
K = int(input())
A =[]
b = len(s)
for i in range(b+1):
      if i+1 < b+1:
        A.append(s[i:i+1])
      if i+2 < b+1:
        A.append(s[i:i+2])
      if i+3 < b+1:
        A.append(s[i:i+3])
      if i+4 < b+1:
        A.append(s[i:i+4])
      if i+5 < b+1:
        A.append(s[i:i+5])
B = set(A)
B = list(B)
B = sorted(B)
print(B[K-1])
### BUGGY CODE ###

import sys
import numpy as np

def gcd(x,y):
    while y:
        x,y = y , x % y 
    return x


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


gcd_all = a[0]
for i in range(1,n):
    gcd_all = gcd(gcd_all,a[i])
    
if gcd_all>1:
    print("not coprime")
    sys.exit()

amax = a.max()

aflag = np.zeros(amax,np.int64)
aflag[a-1] = 1

for i in range(2,amax+1):
    index = (np.arange(amax//i)+1)*i - 1
    count = aflag[index].sum()
    if count>=2:
        print("setwise coprime")
        sys.exit()
else:
    print("pairwise coprime")

### FIXED CODE ###

import sys
import numpy as np
from numba import njit,i8,void

@njit(i8(i8,i8),cache=True)
def gcd(x,y):
    while y:
        x,y = y , x % y 
    return x

@njit(i8(i8[:]),cache=True)
def get_gcd(a):
    gcd_all = a[0]
    for i in range(1,a.size):
        gcd_all = gcd(gcd_all,a[i])
    return gcd_all

@njit(i8(i8[:]),cache=True)
def judge_setwise(a):
    amax = a.max()
    aflag = np.zeros(amax,np.int64)
    aflag[a-1] = 1

    for i in range(2,amax+1):
        index = (np.arange(amax//i)+1)*i - 1
        count = aflag[index].sum()
        if count>=2:
            print("setwise coprime")
            return 0
    else:
        print("pairwise coprime")
        return 0

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


if get_gcd(a)>1:
    print("not coprime")
else:
    judge_setwise(a)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)
from functools import lru_cache

@lru_cache(maxsize=None)
def f(n):
    if n==0:
        return 0
    if n==1:
        return abs(H[1]-H[0])
    return min(f(n-1)+abs(H[n]-H[n-1]),f(n-2)+abs(H[n]-H[n-2]))

n=int(input())
H=tuple(map(int,input().split()))
print(f(n-1))

### FIXED CODE ###

import sys
input=sys.stdin.readline
n=int(input())
H=list(map(int,input().split()))
DP=[0]*n
DP[1]=abs(H[1]-H[0])
for i in range(2,n):
    DP[i]=min(DP[i-1]+abs(H[i]-H[i-1]),DP[i-2]+abs(H[i]-H[i-2]))
print(DP[-1])