Harryxun/stf_run huggingface dataset:
num = int(input())

str2 = input().split(" ")
nums = [int(s) for s in str2]

isOdd = num%2 == 1
available = range(len(nums))

while available > 1:
    for i in range(available / 2)
    nums[i] = nums[2 * i] * nums[2 * i + 1]
    if(ans > 1000000000000000000):
        print(-1)
        quit()
    if isOdd:
        nums[available / 2 + 1] = nums[-1]
        available //= 2
    if isOdd:
        available += 1
    if a == 0:
        print(0)
        quit()
print(ans)
quit()

### FIXED CODE ###

num = int(input())
str2 = input().split(" ")
nums = [int(s) for s in str2]
nums.sort()

ans = 1

for i in range(len(nums)):
    ans = ans * nums[i]
    if(ans > 1000000000000000000):
        print(-1)
        quit()
print(ans)
import sys, math
from functools import lru_cache
from collections import defaultdict
from decimal import Decimal
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N, M = mi()
    S, T = [list(input()), list(input())]
    l = M*N//math.gcd(M, N)

    s = ['']*l
    t = ['']*l

    s[::l//N] = S
    t[::l//M] = T

    for i in range(l):
        if not (s[i] == '' or t[i] == '' or s[i] == t[i]):
            print(-1)
            return

    print(l)




if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys, math
from functools import lru_cache
from collections import defaultdict
from decimal import Decimal
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N, M = mi()
    S, T = [list(input()), list(input())]

    g = math.gcd(N, M)
    l = N*M//g

    for i in range(g):
        if not (S[N//g*i] == T[M//g*i]):
            print(-1)
            return

    print(l)


if __name__ == '__main__':
    main()
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush


h,w,m=[int(x) for x in input().split()]

#defaultdictにすることにより後に使うmax関数のコストを削減
hcnt=defaultdict(int)
wcnt=defaultdict(int)
#存在チェックのアクセスがリストで持たせるより高速
#リストは突っ込めないので注意(hashabeのみOK)
bomb=defaultdict()
#O(H)
for _ in range(m):
    hi,wi=[int(x)-1 for x in input().split()]
    hcnt[hi]+=1
    wcnt[wi]+=1
    bomb[(hi,wi)]=True

#O(H)
hmax=max(hcnt.values())
wmax=max(wcnt.values())

#O(H)
hidx=[x for x,y in hcnt.items() if y==hmax]
widx=[x for x,y in wcnt.items() if y==wmax]

#O(H**2)
ofst=-1
for i in hidx:
    for j in widx:
        if not bomb[(i,j)]:
            ofst=0
            break
                
print(hmax+wmax+ofst)


### FIXED CODE ###

from collections import Counter
from collections import defaultdict
from heapq import heapify
from heapq import heappop
from heapq import heappush
from _collections import defaultdict

h,w,m=[int(x) for x in input().split()]

hcnt=defaultdict(int)
wcnt=defaultdict(int)
bomb=set()
for _ in range(m):
    hi,wi=[int(x)-1 for x in input().split()]
    hcnt[hi]+=1
    wcnt[wi]+=1
    bomb.add((hi,wi))

hmax=max(hcnt.values())
wmax=max(wcnt.values())

hidx=[x for x,y in hcnt.items() if y==hmax]
widx=[x for x,y in wcnt.items() if y==wmax]

ofst=-1
for i in hidx:
    for j in widx:
        if not (i,j) in bomb:
            ofst=0
            break
                
print(hmax+wmax+ofst)
sd=list(input())
t=list(input())
#strsd="?tc????"
#strt="coder"

#strsd="??p??d??"
#strt="abc"

#strsd="ab??p??c"
#strt="abc"

#sd=list(strsd)
#t=list(strt)

lens=len(sd)
lent=len(t)
yn=""
for i in range(lens-lent,-1,-1):
    yn=""
    for ii in range(lent):
        if sd[i+ii]==t[ii] or sd[i+ii]=="?":
            continue
        else:
            yn="NG"
            break
    if yn!="NG":
        yn="itchi"
        break
    
if yn=="NG":
    print("UNRESTORABLE")
else:
    s=""
    if i!=0:
        for ii in range(i):
            if sd[ii]=="?":
                si="a"
            else:
                si=sd[ii]
            s=s+si
    for ti in t:
        s=s+ti
    if i!=lens-lent:
        for ii in range(i+lent,lens,1):
            if sd[ii]=="?":
                si="a"
            else:
                si=sd[ii]
            s=s+si
    print(s)
    



### FIXED CODE ###

sd=list(input())
t=list(input())

yn=""
for i in range(len(sd)-len(t)+1):
    ii=len(sd)-len(t)-i
    yn=""
    for j in range(len(t)):
        if sd[ii+j]!=t[j] and sd[ii+j]!="?":
            yn="NG"
            break
    if yn=="NG":
        continue
    else:
        yn="yes"
        break
    
if yn=="NG" or yn=="": 
    print("UNRESTORABLE")
else:
    for j in range(len(t)):
        sd[ii+j]=t[j]
    for j in range(len(sd)):
        if sd[j]=="?":
           sd[j]="a"
    strt="".join(sd)
    print(strt)
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
lrc=[list(map(int,input().split())) for _ in range(m)]
lrc.sort(key=lambda x:x[0])
lrc.sort(key=lambda x:x[1])

l=[1]
r=[1]
c=[0]
for i in range(m):
    ll,rr,cc=lrc[i]
    l.append(ll)
    r.append(rr)
    c.append(cc)

if l[0]!=1:
    print(-1)
    exit()



import bisect

for i in range(1,m+1):
    x=bisect.bisect_left(r,l[i])
    c[i]+=c[x]


x=bisect.bisect_left(r,n)
ans=min(c[x:])


lrc.sort(key=lambda x:x[0])
ll=lrc[0][0]
rr=lrc[0][1]
for i in range(1,m):
    l,r,c=lrc[i]
    if rr<l:
        print(-1)
        exit()
    rr=r

print(ans)


### FIXED CODE ###


from collections import defaultdict
from heapq import heappop, heappush


class Graph():

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra():

    def __init__(self, graph, start):
        self.g = graph.graph

        self.dist = defaultdict(lambda: float("inf"))
        self.dist[start] = 0

        self.prev = defaultdict(lambda: None)

        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            dist_u, u = heappop(self.Q)

            if self.dist[u] < dist_u:
                continue

            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):

        return self.dist[goal]

    def shortest_path(self, goal):
        path = []
        node = goal

        while node is not None:
            path.append(node)
            node = self.prev[node]

        return path[::-1]


import sys
input=sys.stdin.readline
n,m=map(int,input().split())
g=Graph()

for _ in range(m):
    l,r,c=map(int,input().split())
    g.add_edge(l,r,c)
for i in range(2,n+1):
    g.add_edge(i,i-1,0)


d = Dijkstra(g,1)
ans=d.shortest_distance(n)
print(ans if ans!=float("inf") else -1)
from sys import stdin
from math import sqrt
input = stdin.readline

N = int(input())

ans = 0

seen = [0] * 10 ** 7

for i in range(2, int(sqrt(N)) + 1):
    tmp = i

    while N % tmp == 0:

        if seen[tmp] == 1:
            tmp *= i
            continue
        else:
            N //= tmp
            seen[tmp] = 1
            ans += 1
            tmp *= i

if N != 1 and (ans == 0 or seen[N] == 0):
    ans += 1

print(ans)


### FIXED CODE ###

from sys import stdin
from math import sqrt
input = stdin.readline
N = int(input())

s = [0] * (int(sqrt(N)) + 1)

ans = 0

for i in range(2, int(sqrt(N)) + 1):
    tmp = i

    while N % tmp == 0:
        N //= tmp
        s[tmp] += 1

for i in s:
    for j in range(10 ** 5):
        if (j * (j + 1)) // 2 > i:
            k = j
            break

    ans += k - 1

for i in range(2, int(sqrt(N)) + 1):
    if N % i == 0:
        print(ans)
        exit()

if N != 1:
    ans += 1


print(ans)
v = str(input()).split()
dif_max = -200000

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

print(v[2])

### 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)
cups=[True, False, False]
for line in sys.stdin:
    l= line.strip().split(",")
    if "A"in l and "B"in l:
        cups[0], cups[1]= cups[1], cups[1]
    elif "A"in l and "C"in l:
        cups[0], cups[2]= cups[2], cups[0]
    else:
        cups[1], cups[2]= cups[2], cups[1]
for i in range(3):
    if cups[i]:
        if i== 0:
            print('A')
        elif i== 1:
            print('B')
        else:
            print('C')

### FIXED CODE ###

cup = {"A": 1, "B": 0, "C": 0}
while True:
    try:
        x, y = input().split(",")
    except:
        break
    cup[x], cup[y] = cup[y], cup[x]

for k, v in cup.items():
    if v:
        print(k)
def power(x,y):
    if x%y != 0:
        return 0
    else:
        return 1+power(x/y,y)


def main():
    n = int(input())
    prime=[]
    fact = {}
    num_list = [i for i in range(2,n+1)]
    i = 0
    ans = 1
    mod = 10**9+7
    while i <=n**0.5:
        i = num_list.pop(0)
        prime.append(i)
        for j in num_list:
            if j%i ==0:
                num_list.remove(j)
    prime = prime + num_list

    for i in range(1,n+1):
        for j in prime:
            if i <j:
                break
            elif j in fact.keys():
                fact[j] += power(i,j)
            else:
                fact[j] = power(i,j)
    for i in fact.values():
        ans *= (i+1)
        ans %= mod
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def power(x,y):
    if x%y != 0:
        return 0
    else:
        return 1+power(x/y,y)


def main():
    n = int(input())
    prime=[]
    fact = {}
    num_list = [i for i in range(2,n+1)]
    i = 0
    ans = 1
    if n ==1:
        print(ans)
        exit()
    mod = 10**9+7
    while i <=n**0.5:
        i = num_list.pop(0)
        prime.append(i)
        for j in num_list:
            if j%i ==0:
                num_list.remove(j)
    prime = prime + num_list

    for i in range(1,n+1):
        for j in prime:
            if i <j:
                break
            elif j in fact.keys():
                fact[j] += power(i,j)
            else:
                fact[j] = power(i,j)
    for i in fact.values():
        ans *= (i+1)
        ans %= mod
    print(ans)

if __name__ == '__main__':
    main()
a=input()
b=input()
c=input()

cnta=len(a)
cntb=len(b)
cntc=len(c)

print(a,b,c)
print(cnta,cntb,cntc)

numa=0
numb=0
numc=0

flag=1
if flag==1:
  numa+=1  
elif flag==2:
  numb+=1
elif flag==3:
  numc+=1

if a[numa]=='a':
  flag=1
elif a[numa]=='b':
  flag=2
elif a[numa]=='c':
  flag=3

if flag==1:
  numa+=1  
elif flag==2:
  numb+=1
elif flag==3:
  numc+=1

print(a[numa])
if a[numa]=='a':
  flag=1
elif a[numa]=='b':
  flag=2
elif a[numa]=='c':
  flag=3
  
numa+=1


### FIXED CODE ###

a=list(input())
b=list(input())
c=list(input())
#print(a,b,c)


card=a.pop(0)
#print(card)
flag=0
for i in range(301):
    if card=='a' and len(a)==0 and flag==0:
        ans='A'
        flag=1
    elif card=='b' and len(b)==0 and flag==0:
        ans='B'
        flag=1
    elif card=='c' and len(c)==0 and flag==0:
        ans='C'
        flag=1
    elif flag==0:
        if card=='a':
            card=a.pop(0)
        elif card=='b':
            card=b.pop(0)
        elif card=='c':
            card=c.pop(0)
    
print(ans)
import numpy as np
N=int(input())
S=str(input())
s_list = "abcdefghijklmnopqrstuvwxyz"
count_list = np.zeros(26)
max_count = 0
for i in range(N-1): # N字目で切った場合
  for k in range(i):
    if S[k] in S[N:len(S)]:
      count_list[s_list.index(S[k])] = count_list[s_list.index(S[k])] + 1
  if max_count < n = len([1 for x in count_list if x>0])
print(max_count)

### FIXED CODE ###

import numpy as np
N=int(input())
S=str(input())
s_list = "abcdefghijklmnopqrstuvwxyz"
max_count = 0
for i in range(1,N-1): # N字目で切った場合
  count_list = np.zeros(26)
  for k in range(i):
#    print(i,k,S[k],S[i:len(S)])
    if S[k] in S[i:len(S)]:
      count_list[s_list.index(S[k])] = count_list[s_list.index(S[k])] + 1
  if max_count < len([1 for x in count_list if x>0]):
    max_count = len([1 for x in count_list if x>0])
#  print(count_list)
print(max_count)
x = int(input())
if x = 1:
    print(0)
elif x = 0:
    print(1)


### FIXED CODE ###

x = int(input())
if x == 1:
    print(0)
elif x == 0:
    print(1)
A,P = map(int,input().split())
print((A*3+P)//2)

### FIXED CODE ###

N,A,B=map(int,input().split())
print(min(N*A,B))
N,A=map(int,open(0).read().split());l=[0]*4
for a in A:l[a&3]+=1
print("YNeos"[d[1]+d[3]>1+d[0]::2])

### FIXED CODE ###

N,*A=map(int,open(0).read().split());l=[0]*4
for a in A:l[a&3]+=1
o=l[1]+l[3];print("YNeos"[o>1+l[0]or o-1==l[0]and l[2]>0::2])
# coding:utf-8

import math

n, y = map(int, input().split())

dist_list = [abs(x-y) for x in map(int, input().split())]

if n == 1:
    d = dist_list[0]
else:
    for i in reversed(range(n)):
        if i == n-1:
            d = math.gcd(dist_list[i], dist_list[i-1])
        else:
            d = math.gcd(dist_list[i-1], d)    

print(d)


### FIXED CODE ###

# coding:utf-8

from fractions import gcd 

n, y = map(int, input().split())

dist_list = [abs(x-y) for x in map(int, input().split())]

if n == 1:
    d = dist_list[0]
else:
    d = gcd(dist_list[1], dist_list[0])
    for i in range(n-2):
        d = gcd(d, dist_list[i+1])

print(d)
=int(input())
List=list(map(int, input().split()))
cnt=[0]*(n-1)
ans=0
for i in range(n-1):
  if List[i]>=List[i+1]:
    if i==0:
      cnt[i]=1
    else:
      cnt[i]=cnt[i-1]+1
print(max(cnt))

### FIXED CODE ###

n=int(input())
List=list(map(int, input().split()))
ans = 0
cnt = 0
for i in range(n-1):
  if List[i]>=List[i+1]:
    if i==0:
      cnt=1
    else:
      cnt+=1
      ans = max(ans, cnt)
  else:
    cnt=0
print(ans)
Print(2**3)


### FIXED CODE ###

import sys

x = int(sys.stdin.readline())
print(x**3)
#B(別解)
n=int(input())
x=math.ceil(n/1.08)
if math.floor(x*1.08)==n:
    print(x)
else:
    print(":(")

### FIXED CODE ###

#B(別解)
import math
n=int(input())
x=math.ceil(n/1.08)
if math.floor(x*1.08)==n:
    print(x)
else:
    print(":(")
import sys
import numba

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@numba.njit
def main(N):
    x = 0
    for a in range(1, N+1):
        for b in range(1, N//a+1):
            x += a*b
    return x

from my_module import main

N = int(read())
print(main(N))


### FIXED CODE ###

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def prime_table(N):
    is_prime = np.zeros(N, np.int64)
    is_prime[2:3] = 1
    is_prime[3::2] = 1
    for p in range(3, N, 2):
        if p * p >= N:
            break
        if is_prime[p]:
            is_prime[p * p::p + p] = 0
    return is_prime, np.where(is_prime)[0]

def main(N, primes):
    div = np.ones(N + 1, dtype=np.int64)
    for p in primes:
        for i in range(N // p + 1):
            div[p * i] += div[i]
    div *= np.arange(N + 1)
    return div.sum()

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8, i8[:]))
    cc.compile()

from my_module import main

N = int(read())
is_prime, primes = prime_table(N + 1)
print(main(N, primes))
a=int(input())
b=[sorted(input()) for j in range(a)]
c=[[0for i in range(26)] for j in range(a)]
for i in range(a):
  for j in range(10):
    c[i][ord(b[i][j])-97]+=1
sum=0
d=1
c.sort()
for i in range(a-1):
  if c[i]==c[i+1]:
    d+=1
  else:
    sum+=d*(d-1)//2
    d=1
  if i==a-2:
    sum+=d*(d-1)//2
    
print(sum)

### FIXED CODE ###

import heapq
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a)]
c.sort()
d=[[0]for i in range(b)]
sum=0
for i,j in c:
  if i<=b:
    d[i-1].append(j)
e=[]

for i in d:
  for j in i:
    heapq.heappush(e,-j)
  sum-=heapq.heappop(e)
      
    
  
print(sum)
while True:
    sute = map(int,raw_input().split()) 
    num = map(int,raw_input().split())
    for i in range(len(num) - 1):
        print "%d" % num[len(num) - i - 1],
    print num[0]

### FIXED CODE ###

sute = map(int,raw_input().split()) 
num = map(int,raw_input().split())
for i in range(len(num) - 1):
    print "%d" % num[len(num) - i - 1],
print num[0]
import heapq
def main():
  N, Q = list(map(int, input().split()))
  STX = tuple(list(map(int, input().split())) for _ in range(N))
  D = tuple([int(input()) for _ in range(Q)])

  L = []
  for s, t, x in STX:
    L.append((x, s - x, t - x))

  L.sort(key = lambda x: x[1])
  q = []
  cnt = 0
  push = heapq.heappush
  pop = heapq.heappop
  t = []
  for i in range(Q):
    while cnt < len(L) and D[i] >= L[cnt][1]:
      if t != []:
        t = []
        push(q, t)
      push(q, L[cnt])
      cnt += 1
    if t != [] and t[2] > D[i]:
      print(t[0])
    else:
      while q != []:
        t = pop(q)
        if t[2] > D[i]:
          print(t[0])
          break
      else:
        t = []
        print(-1)

main()


### FIXED CODE ###

import heapq
def main():
  N, Q = list(map(int, input().split()))
  STX = tuple(list(map(int, input().split())) for _ in range(N))
  D = tuple([int(input()) for _ in range(Q)])

  L = []
  for s, t, x in STX:
    L.append((x, s - x, t - x))

  L.sort(key = lambda x: x[1])
  q = []
  cnt = 0
  push = heapq.heappush
  pop = heapq.heappop
  t = []
  for i in range(Q):
    while cnt < len(L) and D[i] >= L[cnt][1]:
      if t != []:
        push(q, t)
        t = []
      push(q, L[cnt])
      cnt += 1
    if t != [] and t[2] > D[i]:
      print(t[0])
    else:
      while q != []:
        t = pop(q)
        if t[2] > D[i]:
          print(t[0])
          break
      else:
        t = []
        print(-1)

main()
import numpy as np
n, a = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
xs=sum(x)
dp= np.zeros((n+1,xs*n+1),dtype=int)
dp[0][0][0]=1
ans=0

for k in range(1,n+1):
  for i in range(0,k+1):
    for j in range(0,xs*n+1):
      if j>=x[k-1] and i>=1:
        dp[i][j]= dp[i][j] + dp[i-1][j-x[k-1]]
      else:
        dp[i][j]= dp[i][j] 
      
for i in range(1,n+1):
  ans+=dp[i][a*i]

print(ans)

### FIXED CODE ###

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

dp=[[0 for i in range(a*n+1)] for j in range(n+1)]
dp[0][0]=1
ans=0
f=0

for k in range(1,n+1):
  kx=x[k-1]
  f+=kx
  for i in range(k,0,-1):
    for j in range(kx,a*n+1):
      dp[i][j] += dp[i-1][j-kx]
      if j > f:
        break
      
for i in range(1,n+1):
  ans+=dp[i][a*i]

print(ans)
N = int(input())
S = input()

a_lst = ([i for i, x in enumerate(S) if x == 'A'])
count = 0
for j in a_lst:
    if S[j+1] == 'B' and S[j+2] == 'C':
        count += 1
print(count)

### FIXED CODE ###

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

a_lst = ([i for i, x in enumerate(S) if x == 'A'])
count = 0
for j in a_lst:
    if len(S) >= j + 3:
        if S[j+1] == 'B' and S[j+2] == 'C':
            count += 1
print(count)
s=input()
if s ==　"Sunny":
    print("Cloudy")
elif s ==　"Cloudy":
    print("Rainy")
else:
    print("Sunny")


### FIXED CODE ###

s=input()
if s=="Sunny":
  print("Cloudy")
if s=="Cloudy":
  print("Rainy")
if s=="Rainy":
  print("Sunny")
(x, y, A, B, C) = map(int, raw_input().split())

ps = sorted(map(int, raw_input().split()), reverse=True)[:x]
qs = sorted(map(int, raw_input().split()), reverse=True)[:y]
cs = sorted(map(int, raw_input().split()))

tot = sum(ps) + sum(qs)

while cs and (cs[-1] > ps[-1] or cs[-1] > qs[-1]):
    if ps and qs:
        if ps[-1] < qs[-1]:
            tot -= ps.pop()
            tot += cs.pop()
        else:
            tot -= qs.pop()
            tot += cs.pop()
    elif ps:
        tot -= ps.pop()
        tot += cs.pop()
    elif qs:
        tot -= qs.pop()
        tot += cs.pop()
    else:
        assert False
# print ps, qs

print tot



### FIXED CODE ###

(x, y, A, B, C) = map(int, raw_input().split())

ps = sorted(map(int, raw_input().split()), reverse=True)[:x]
qs = sorted(map(int, raw_input().split()), reverse=True)[:y]
cs = sorted(map(int, raw_input().split()))

tot = sum(ps) + sum(qs)

while cs and ((ps and cs[-1] > ps[-1]) or (qs and cs[-1] > qs[-1])):
    if ps and qs:
        if ps[-1] < qs[-1]:
            tot -= ps.pop()
            tot += cs.pop()
        else:
            tot -= qs.pop()
            tot += cs.pop()
    elif ps:
        tot -= ps.pop()
        tot += cs.pop()
    elif qs:
        tot -= qs.pop()
        tot += cs.pop()
    else:
        break
# print ps, qs

print tot
nn=int(input())
kk=int(input())
num_value = list(map(int, input().split())) 
num_value.sort()
goukei=0
for i in range(kk):
    goukei=goukei+num_value[kk]
print(goukei)


### FIXED CODE ###

nn,kk=map(int,input().split())
num_value = list(map(int, input().split())) 
num_value.sort()
gokei=0
for i in range(kk):
   gokei=gokei+num_value[i]
print(gokei)
x=input()
a=[1]
for i in range(1,len(x)):
    if x[i]==x[i-1]:
        a[-1]+=1
    else:a+=[1]
ans=0    
if x[0]=="T":
    ans+=a.pop(0)
if x[-1]=="S":
    ans+=a.pop(-1)
    
while len(a)>1:
    a=[i-j for i,j in zip(a[::2],a[1::2]) if i!=j]
    while a and a[0]<0:
        ans+=abs(a.pop(0))
    while a and a[-1]>0:
        ans+=a.pop(-1)
    b=[]    
    if a:
        b=[a[0]]
        for i in range(1,len(a)):
            if a[i]*a[i-1]>0:
                b[-1]+=a[i]
            else:b+=a[i]
    a=[abs(i) for i in b]
            
print(ans+abs(a[0]) if a else ans)

### FIXED CODE ###

a=[]
for i in input():
    if i=="S":
        a+=i
    
    if a:
        if i=="T" and a[-1]=="T":
            a+=i
        if i=="T" and a[-1]=="S":
            a.pop(-1)
    elif i=="T" and len(a)==0:
        a+=i    
print(len(a))
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def ev(n):
    return 0.5*(n+1)


def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))

    p_ev = list(map(ev, p))

    s = np.cumsum(p_ev)

    ans = []

    for i in range(n - k):
        ans.append(s[i + k] - s[i])

    print(max(ans))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def ev(n):
    return 0.5*(n+1)


def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))

    p_ev = list(map(ev, p))

    s = np.cumsum(p_ev)
    s = np.insert(s, 0, 0)

    ans = []

    for i in range(n - k+1):
        ans.append(s[i + k] - s[i])

    print(max(ans))


if __name__ == '__main__':
    main()
n,x = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
d = 0
i = 0
while d<=x:
    d += l[i]
    i += 1
print(i)


### FIXED CODE ###

from itertools import accumulate
n,x = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
ruiseki = list(accumulate(l))
ruiseki.insert(0,0)
i = 0
#print(ruiseki)
while i < len(ruiseki) and ruiseki[i] <= x:
    i += 1
print(i)
import sys
args = sys.argv[1]
#??????????????????????????????????????????????????§????????????????????????
with open(args) as f:
	x = f.readlines()
	i = 0
	while x[i] != 0:
		print("Case " + str(i+1) + ":" + str(x))
		i += 1
		

### FIXED CODE ###

#x = []
i = 0
while True:
	x = int(input())
	if x == 0:
		break
	print("Case " + str(i+1) + ": " + str(x))
	i += 1