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

S = input()
import re


def nchars(s, n):
    assert n > 0
    reg = re.compile("(.)\\1{%d,}" % (n - 1)) 
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]
        
        
def n_sum(n):
  return n*(n+1)//2
        
s_l = list(nchars(S,1))
s_l_length = len(s_l)
answer=0
if s_l[0][0]=='<':
  if s_l_length%2==0:
    for i in range(0,s_l_length,2):
      s_1=s_l[i]
      s_2=s_l[i+1]
      s_1_l=len(s_1)
      s_2_l=len(s_2)
      if s_1_l<=s_2_l:
        answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
      else:
        answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  else:
    for i in range(0,s_l_length,2):
      if i==s_l_length-1:
        answer+=n_sum(len(s_l[i]))
      else:
        s_1=s_l[i]
        s_2=s_l[i+1]
        s_1_l=len(s_1)
        s_2_l=len(s_2)
        if s_1_l<=s_2_l:
          answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
        else:
          answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
          
else:
  answer+=n_sum(len(s_l.pop(0)))
  s_l_length-=1
  if s_l_length%2==0:
    for i in range(0,s_l_length,2):
      s_1=s_l[i]
      s_2=s_l[i+1]
      s_1_l=len(s_1)
      s_2_l=len(s_2)
      if s_1_l<=s_2_l:
        answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
      else:
        answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  else:
    for i in range(0,s_l_length,2):
      if i==s_l_length-1:
        answer+=n_sum(len(s_l[i]))
      else:
        s_1=s_l[i]
        s_2=s_l[i+1]
        s_1_l=len(s_1)
        s_2_l=len(s_2)
        if s_1_l<=s_2_l:
          answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
        else:
          answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  
      
print(answer)

### FIXED CODE ###

S = input()
from itertools import groupby
S_length = len(S)
k = 1
s_l=[k*len(list(g)) for k, g in groupby(S)]
  
        
        
def n_sum(n):
  return n*(n+1)//2
        

s_l_length = len(s_l)
answer=0
if s_l[0][0]=='<':
  if s_l_length%2==0:
    for i in range(0,s_l_length,2):
      s_1=s_l[i]
      s_2=s_l[i+1]
      s_1_l=len(s_1)
      s_2_l=len(s_2)
      if s_1_l<=s_2_l:
        answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
      else:
        answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  else:
    for i in range(0,s_l_length,2):
      if i==s_l_length-1:
        answer+=n_sum(len(s_l[i]))
      else:
        s_1=s_l[i]
        s_2=s_l[i+1]
        s_1_l=len(s_1)
        s_2_l=len(s_2)
        if s_1_l<=s_2_l:
          answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
        else:
          answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
          
else:
  answer+=n_sum(len(s_l.pop(0)))
  s_l_length-=1
  if s_l_length%2==0:
    for i in range(0,s_l_length,2):
      s_1=s_l[i]
      s_2=s_l[i+1]
      s_1_l=len(s_1)
      s_2_l=len(s_2)
      if s_1_l<=s_2_l:
        answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
      else:
        answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  else:
    for i in range(0,s_l_length,2):
      if i==s_l_length-1:
        answer+=n_sum(len(s_l[i]))
      else:
        s_1=s_l[i]
        s_2=s_l[i+1]
        s_1_l=len(s_1)
        s_2_l=len(s_2)
        if s_1_l<=s_2_l:
          answer+=n_sum(s_1_l-1)+n_sum(s_2_l)
        else:
          answer+=n_sum(s_1_l)+n_sum(s_2_l-1)
  
      
print(answer)
### BUGGY CODE ###

import itertools

N = int(input())

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

con = 0

edge = list(itertools.combinations(L,3))

for i in range(0,len(edge)):
	a = edge[i][0]
	b = edge[i][1]
	c = edge[i][2]
	total = sum(edge[i])
	if a < b + c and b < a + c and c < a + b:
		con += 1
		
print(con)

### FIXED CODE ###

from bisect import bisect_left

N = int(input())

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

L.sort()

con = 0

for i in range(0,N):
  for j in range(i + 1,N):
    a = L[i]
    b = L[j]
    #a + bよりでかい最小の数のインデックス
    p = bisect_left(L,a + b)
    #cとbの間の区間を取る
    con += (p - 1) - j


print(con)
### BUGGY CODE ###

from collections import deque

import sys
input = sys.stdin.readline


n = int(input())
a_list = {i:None for i in range(n)}
num = 0
day = 0
for i in range(n):
    a_list[i] = deque([int(i) - 1 for i in input().split()])

for kkk in range(n * (n - 1) // 2):
    visit = set([])
    day += 1
    for j in range(n):
        if j not in visit:
            if len(a_list[j]) > 0:
                k = a_list[j][0]
                if k not in visit:
                    if a_list[k][0] == j:
                        num += 1
                        visit.add(a_list[j].popleft())
                        visit.add(a_list[k].popleft())
                    if num >= n * (n - 1) // 2:
                        print(day)
                        exit()
    if (len(visit) == 0):
        print(-1)
        exit()
    if num >= n * (n - 1) // 2:
        print(day)
        exit()

### FIXED CODE ###

from collections import deque
n = int(input())
a_list = []
for i in range(n):
    a_list.append(deque([int(aa) - 1 for aa in input().split()]))
day = 0
battle = 0
for _ in range(n * (n - 1) // 2):
    if battle == n * (n - 1) // 2:
        break
    day += 1
    battle_today = 0
    tomorrow = set([])
    if (day == 1):
        player = set([i for i in range(n)])
    for i in player:
        if len(a_list[i]) == 0:
            continue
        j = a_list[i][0]
        if (i == a_list[j][0]) & (j not in tomorrow) & (len(a_list[j]) > 0) & (i not in tomorrow):
            tomorrow.add(i)
            tomorrow.add(a_list[i][0])
            battle += 1
            battle_today += 1
            a_list[i].popleft()
            a_list[j].popleft()
    player = tomorrow
    if battle_today == 0:
        day = -1
        break
print(day)
### BUGGY CODE ###

S = list(input())
Q = int(input())
t_count = 0

for i in range(Q):
  list_ = list(input().split())
  T = int(list_[0])
  if T == 1:
    t_count += 1
  else:
    if t_count%2 == 1:
      S.reverse()
      t_count = 0
    F, C = int(list_[1]), list_[2]
    if F == 1:
      S.insert(0,C)
    else:
      S.append(C)
if t_count%2 == 1:
      S.reverse()
ans = ''.join(S)
print(ans)

### FIXED CODE ###

S = list(input())
Q = int(input())
t_count = 0
before = []
after = []

for i in range(Q):
  list_ = list(input().split())
  T = int(list_[0])
  if T == 1:
    t_count += 1
  else:
    F, C = int(list_[1]), list_[2]
    if F == 1:
      if t_count%2 == 0:
        before.append(C)
      else:
        after.append(C)
    else:
      if t_count%2 == 0:
        after.append(C)
      else:
        before.append(C)
before.reverse()
S.extend(after)
before.extend(S)
if t_count%2 == 1:
  before.reverse() 
ans = ''.join(before)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    m = 10**9 + 7
    B =[a%m for a in A]
    ans = 0
    for i in range(N-1):
        for j in range(i+1,N):
            # ans += (A[i]*A[j])%(10**9+7)
            ans += (A[i]*A[j])
    print(ans%m)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    W = [0]*N
    W[0] = A[0]
    for i in range(1,N):
        W[i] += W[i-1] + A[i]
    ans = 0
    for i in range(N-1):
        ans += A[i]*(W[N-1] - W[i])
    print(ans%(10**9+7))

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

N, M = map(int, input().split())
childs = [[] for _ in range(N)]
for i in range(M):
    p, c = map(int, input().split())
    childs[p-1].append(c)

stack = list(range(1, N+1))
# dp[n]: nに到達する最長のパス
dp = [0] * N
while stack:
    n = stack.pop()
    for nc in childs[n-1]:
        if dp[nc-1] < dp[n-1] + 1:
            stack.append(nc)
            dp[nc-1] = dp[n-1] + 1

print(max(dp))


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
childs = [[] for _ in range(N)]
for i in range(M):
    p, c = map(int, input().split())
    childs[p-1].append(c-1)

depth = [-1] * N
def dfs(n):
    if depth[n] != -1:
        return depth[n]
    if childs[n]:
        depth[n] = max((dfs(nc) for nc in childs[n])) + 1
    else:
        depth[n] = 0
    return depth[n]

print(max((dfs(n) for n in range(N))))
### BUGGY CODE ###


def main():
    N, K  = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [10**9] * N
    dp[0] = 0

    for i in range(N):
        if i == 0:
            pass
        elif i == 1:
            dp[1] = abs(h[1]-h[0])
        else:
            dp[i] = min([dp[i-j] + abs(h[i]-h[i-j]) for j in range(1, min(K,i)+1)])
    print(dp[N-1])

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N, K  = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [10**9] * N
    dp[0] = 0

    for i in range(N):
        dp[i] = min([dp[i-j] + abs(h[i]-h[i-j]) for j in range(min(K,i)+1)])
    print(dp[N-1])

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



from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline




def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

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

smod=[]
bef=0
for i in range(len(S)):
    bef+=(S[i]*(10**i))%2019
    smod.append(bef%2019)
    
cnt=[0]*2020
for sm in smod:
    cnt[sm]+=1

cnt[0]+=1

res=0
for sc in cnt:
    res+=sc*(sc-1)/2
    
    
print(int(res))

#print(smod)

#print(cnt[:10])

### FIXED CODE ###



from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline




def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

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

N=len(S)
smod=[0]*N
bef=0
b=1

for i in range(len(S)):
    l=N-i-1
    bef+=(S[l]*(b))%2019
    smod[l]=bef%2019
    #smod.append(bef%2019)
    b=(b*10)%2019
    
cnt=[0]*2020
for sm in smod:
    cnt[sm]+=1

cnt[0]+=1

res=0
for sc in cnt:
    res+=sc*(sc-1)/2
    
    
print(int(res))

#print(smod)

#print(cnt[:10])
### BUGGY CODE ###

from collections import deque
inf=float("inf")


def BFS():
    color=[["white" for _ in range(w)] for _ in range(h)]
    D=[[inf for _ in range(w)] for _ in range(h)]
    queue=deque([])

    x,y=C
    x -=1
    y -=1
    queue.append([x,y])
    D[x][y]=0

    for i in range(h):
        for j in range(w):
            if S[i][j]=="#":
                color[i][j]="black"

    while len(queue)>0:
        x,y=queue.popleft()
        for i,j in [[1,0],[0,1],[-1,0],[0,-1]]:
            X,Y=x+i,y+j
            if 0<=X<h and 0<=Y<w:
                if color[X][Y]!="black":
                    D[X][Y]=min(D[X][Y],D[x][y])
                    color[X][Y]="gray"
                    queue.appendleft([X,Y])

        for i in range(max(0,x-2),min(h,x+3)):
            for j in range(max(0,y-2),min(w,y+3)):
                X,Y=i,j
                if 0<=X<h and 0<=Y<w:
                    if color[X][Y]!="black":
                        D[X][Y]=min(D[X][Y],D[x][y]+1)
                        color[X][Y]="gray"
                        queue.append([X,Y])
        color[x][y]="black"

    return D[G[0]-1][G[1]-1]


h,w=map(int,input().split())
C=list(map(int,input().split()))
G=list(map(int,input().split()))
S=[list(input()) for _ in range(h)]

D=BFS()
print(D if D!=inf else -1)

### FIXED CODE ###

from collections import deque
import sys
input=sys.stdin.readline
inf=float("inf")


def BFS():
    D=[[inf for _ in range(w)] for _ in range(h)]
    queue=deque()
    queue.append([Cx-1,Cy-1,0])
    D[Cx-1][Cy-1]=0

    while len(queue)>0:
        x,y,cnt=queue.popleft()
        for i,j in [[1,0],[0,1],[-1,0],[0,-1]]:
            X,Y=x+i,y+j
            if 0<=X<h and 0<=Y<w:
                if S[X][Y]=="." and D[X][Y]>cnt:
                    D[X][Y]=cnt
                    queue.appendleft([X,Y,cnt])

        for X in range(max(0,x-2),min(h,x+3)):
            for Y in range(max(0,y-2),min(w,y+3)):
                if S[X][Y]=="." and D[X][Y]>cnt+1:
                    D[X][Y]=cnt+1
                    queue.append([X,Y,cnt+1])

    return D[Dx-1][Dy-1]


h,w=map(int,input().split())
Cx,Cy=map(int,input().split())
Dx,Dy=map(int,input().split())
S=[list(input()) for _ in range(h)]

D=BFS()
print(D if D!=inf else -1)
### BUGGY CODE ###

k = int(input())

if k % 2 == 0:
    print(-1)
else:
    ans = 1
    num = 7
    while True:
        if int(num) % k == 0:
            print(ans)
            break
        else:
            ans += 1
            num += 7 * pow(10, ans - 1, k)
            num %= k


### FIXED CODE ###

k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
else:
    ans = 1
    num = 7 % k
    temp = 7 % k
    while True:
        if num % k == 0:
            print(ans)
            break
        else:
            ans += 1
            temp = temp * 10 % k
            num += temp % k
            num %= k
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Sep  6 23:39:24 2020

@author: liang
"""
from scipy.special import comb

counter = [0]*2019
counter[0] = 1 # 0 = 0 (mod 2019)

S = input()
for i in range(1,len(S)+1):
    tmp = int(S[-i:])
    #print(tmp%2019)
    counter[tmp%2019] += 1

ans = 0
for i in range(2019):
    ans += comb(counter[i], 2, exact=True)
    
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Sep  6 23:39:24 2020

@author: liang
"""
#from scipy.special import comb

counter = [0]*2019
counter[0] = 1 # 0 = 0 (mod 2019)

S = input()
tmp = 0
"""
#大きい数を一気に掛けない
for i in range(1,len(S)+1):
    tmp += int(S[-i])*10**(i-1)    #スライスの方が早い（けど、漸化式的に累積和を出せ）
    #print(tmp%2019)
    tmp %= 2019                    #大きい数を割るな
    counter[tmp%2019] += 1

ans = 0
for i in range(2019):
    if counter[i] >= 2:
        #ans += comb(counter[i], 2, exact=True)
        ans += counter[i]*(counter[i]-1)//2
print(ans)
"""
MOD = 2019
#reversed(s) ?
t = 1
for i in range(1,len(S)+1):
    tmp += int(S[-i])*t
    #print("A", tmp)
    tmp %= MOD 
    t *= 10
    #print("B", tmp)
    t %= MOD
    #print(tmp)
    counter[tmp] += 1
    
print(sum(i*(i-1)//2 for i in counter))
### BUGGY CODE ###

from sys import stdin
from collections import defaultdict,deque
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n)]
        self.rank = [0]*n
        self.n = n
    def find(self,x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    def same(self,x,y):
        return bool(self.find(x)==self.find(y))

    def allset(self):
        d = defaultdict(list)
        for i in range(self.n):
            d[self.find(i)] += [i]
        t = list(d.keys())
        for i in t:
            d[i].sort()
            d[i] = deque(d[i])
        return d

def main():
    N,M = map(int,stdin.readline().split())
    uf = UnionFind(N)
    p = list(map(int,stdin.readline().split()))
    ans = 0
    for _ in range(M):
        x,y = map(int,stdin.readline().split())
        x -= 1
        y -= 1
        uf.union(x,y)
    d = uf.allset()
    for i in range(N):
        p[i] -= 1
    for i in range(N):
        tmp = p[i]
        r = uf.find(tmp)
        if uf.same(r,i):
            pre = int(p[i])
            if i in d[r]:
                new = i
                d[r].remove(i)
            else:
                new = d[r].popleft()
            swap = p.index(new)
            p[i] = new
            p[swap] = pre
    for i in range(N):
        if p[i] == i:ans += 1
    print(ans)
    #print(*list(map(lambda x:x+1,p)))
if __name__ == "__main__":
    main()

### FIXED CODE ###

from sys import stdin
from collections import defaultdict,deque
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n)]
        self.rank = [0]*n
        self.n = n
    def find(self,x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    def same(self,x,y):
        return bool(self.find(x)==self.find(y))



def main():
    N,M = map(int,stdin.readline().split())
    uf = UnionFind(N)
    p = list(map(int,stdin.readline().split()))
    p = list(map(lambda x: x-1,p))
    ans = 0
    for _ in range(M):
        x,y = map(int,stdin.readline().split())
        x -= 1
        y -= 1
        uf.union(x,y)
    for i in range(N):
        tmp = p[i]
        if not uf.same(tmp,i):continue
        else:ans += 1
    print(ans)
    #print(*list(map(lambda x:x+1,p)))
if __name__ == "__main__":
    main()
### BUGGY CODE ###

n,x,y = map(int,input().split())
dists = []
for i in range(n):
    for j in range(i):
        dist = min(abs(i-j),abs((i+1)-x)+1+abs((j+1)-y),abs((j+1)-x)+1+abs((i+1)-y))
        dists.append(dist)
    
for i in range(n-1):
    print(sum([1 for dist in dists if dist == i+1]))

### FIXED CODE ###

n,x,y = map(int,input().split())
dists = [0]*(n)
for i in range(1,n+1):
    for j in range(1,i):
        dist = min(abs(i-j),abs(i-x)+1+abs(j-y),abs(j-x)+1+abs(i-y))
        dists[dist] = dists[dist]+1
    
for i in range(len(dists) - 1):
    print(dists[i+1])
### BUGGY CODE ###

import sys
# print(sys.getrecursionlimit())
sys.setrecursionlimit(3000000)
# print(sys.getrecursionlimit())

R, C, K = map(int, input().split())

mesh = [[0]*C for _ in range(R)]

for _ in range(K):
    r, c, v = map(int, input().split())
    mesh[r-1][c-1] = v

# print(*mesh,sep='\n')

def big3(d):
    return sorted(d, reverse=True)[:3]

def dfs(i, j, k, s):
    # print('i {} j {} k {} s {}'.format(i,j,k,s))

    if i == R-1 and j == C-1:
        r = big3(k + [mesh[i][j]])
        # print('r {}'.format(r))
        return s + sum(r)

    # if i == R or j == C: return val

    # nx_k = k + [mesh[i][j]] if mesh[i][j] > 0 else k
    nx_k = big3(k + [mesh[i][j]])

    val = 0
    if j+1 <= C-1:
        val = dfs(i, j+1, nx_k, s)

    if i+1 <= R-1:
        pre = sum(nx_k)
        v = dfs(i+1, j, [], s + pre)
        val = max(val, v)
        # print('pre {} v {}'.format(pre,v))

    return val

# ans = dfs(0, 0, 1 if mesh[0][0] > 0 else 0)
ans = dfs(0, 0, [], 0)
print(ans)


### FIXED CODE ###

R, C, K = map(int, input().split())

V = [[0]*(C+1) for _ in range(R+1)]
for _ in range(K):
    r, c, v = map(int, input().split())
    V[r][c] = v

pre = [[0]*(3+1) for _ in range(C+1)]
for i in range(R+1):
    now = [[0]*(3+1) for _ in range(C+1)]
    for j in range(C+1):
        for k in range(3+1):
            if i-1 >= 0:
                now[j][0] = max(now[j][0], pre[j][k])
                now[j][1] = max(now[j][1], pre[j][k] + V[i][j])

            if j-1 >= 0:
                now[j][k] = max(now[j][k], now[j-1][k])
                if k-1 >= 0:
                    now[j][k] = max(now[j][k], now[j-1][k-1] + V[i][j])
    pre = now

print(max(now[C]))
### BUGGY CODE ###

S = list(map(int,input()))
N = len(S)
i = 0
while i < len(S)-1:
    if S[i] != S[i+1]:
        S[i:] = S[i+2:]
        i -=1
    else:
        i +=1
print(N-len(S))

### FIXED CODE ###

S = list(map(int,input()))
N = len(S)

ones = sum(S)
zeros = N - ones
print(2*min(ones,zeros))
### BUGGY CODE ###

input()
*a, = map(int, input().split())
ans = 1
for i in a: ans *= i
print(ans if ans<=10**18 else -1)

### FIXED CODE ###

input()
*a, = map(int, input().split())
if 0 in a:
    print(0)
    exit()
ans = 1
a = sorted(a)[::-1]
for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()
print(ans)
### BUGGY CODE ###

num = int(input())
taro, hanako = 0 ,0
for i in range(num):
    lst = list(map(str, input().split()))
    while 1:
        j = 0
        if lst[0] == lst[1]:
            taro = taro + 1
            hanako = hanako + 1
            break
        else:
            first = ord(lst[0][j:j+1])
            second = ord(lst[1][j:j+1])
            if first > second:
                taro = taro + 3
                break
            elif first < second:
                hanako = hanako + 3
                break
print(str(taro) + " " + str(hanako))


### FIXED CODE ###

taro = hanako = 0
for i in range(int(input())):
    lst = list(map(str, input().split()))
    while 1:
        if lst[0] == lst[1]:
            taro = taro + 1
            hanako = hanako + 1
            break
        else:
            length = min(len(lst[0]),len(lst[1]))
            for j in range(length):
                first = ord(lst[0][j:j+1])
                second = ord(lst[1][j:j+1])
                if first > second:
                    taro = taro + 3
                    break
                elif first < second:
                    hanako = hanako + 3
                    break
                elif j == length - 1:
                    if len(lst[0]) > len(lst[1]):
                        taro = taro + 3
                    elif len(lst[0]) < len(lst[1]):
                        hanako = hanako + 3
                    break
            break
print(str(taro) + " " + str(hanako))
### BUGGY CODE ###

import sys
from functools import reduce
sys.setrecursionlimit(2000000001)

def solve(n,k,ar,dp,x):
	ab = abs; mn = min
	if x>=n-2: return dp[x]
	if not dp[x] is -1: return dp[x]
	t = [ab(ar[x]-ar[i])+solve(n,k,ar,dp,i) for i in range(x+1,mn(n,x+k+1))]
	dp[x] = reduce(lambda a,b : a if a < b else b,t)
	return dp[x]

def main():
	I = lambda:map(int,sys.stdin.readline().split())
	pr = lambda x:sys.stdout.write(f'{x}\n')
	n,k, ar = *I(), [*I()]
	dp = [-1]*(n-2) + [abs(ar[-2]-ar[-1]),0]
	pr(solve(n,k,ar,dp,0))

main()

### FIXED CODE ###

import sys
from functools import reduce
sys.setrecursionlimit(2000000001)

def solve(n,k,ar,dp,x):
	ab = abs; mn = min
	if x>=n-2: return dp[x]
	if not dp[x] is -1: return dp[x]
	# t = [ for i in range(x+1,mn(n,x+k+1))]
	t = map(lambda i:ab(ar[x]-ar[i])+solve(n,k,ar,dp,i), range(x+1,mn(n,x+k+1)))
	dp[x] = reduce(lambda a,b : a if a < b else b,t)
	return dp[x]

def main():
	I = lambda:map(int,sys.stdin.readline().split())
	pr = lambda x:sys.stdout.write(f'{x}\n')
	n,k, ar = *I(), [*I()]
	dp = [-1]*(n-2) + [abs(ar[-2]-ar[-1]),0]
	pr(solve(n,k,ar,dp,0))

main()