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

a, b, c, d, e, f = map(int, input().split())
w = []
for i in range(f):
    for j in range(f):
          t = 100 * (a * i + b * j)
          if 0 < t <= f:
              w.append(t)
s = []
for i in range(f):
    for j in range(f):
          t = c * i + d * j
          if t <= f:
              s.append(t)

ans_ws = -1
ans_s = -1
buf = -1
for water in w:
    for sugar in s:
          if water + sugar > f:
              continue
          concentration = (sugar * 100) / (water + sugar)
          if concentration <= (e * 100) / (100 + e):
              if buf < concentration:
                  buf = concentration
                  ans_ws = water + sugar
                  ans_s = sugar
print(ans_ws, ans_s)

### FIXED CODE ###

a, b, c, d, e, f = map(int, input().split())
w = []
for i in range(f // 100 + 2):
    for j in range(f // 100 + 2):
          t = 100 * (a * i + b * j)
          if 0 < t <= f:
              w.append(t)
s = []
for i in range(f // c + 2):
    for j in range(f // d + 2):
          t = c * i + d * j
          if t <= f:
              s.append(t)

ans_ws = -1
ans_s = -1
buf = -1

sat = (e * 100) / (100 + e)
for water in w:
    for sugar in s:
          ttl = (water + sugar)
          if ttl > f:
              continue
          concentration = (sugar * 100) / ttl
          if concentration <= sat:
              if buf < concentration:
                  buf = concentration
                  ans_ws = ttl
                  ans_s = sugar
print(ans_ws, ans_s)
### BUGGY CODE ###

N, M = map(int, input().split())
a, b = [], []
ans = 0
INF = float('inf')
for n in range(N):
    tmp1, tmp2 = map(int, input().split())
    a.append(tmp1)
    b.append(tmp2)

count = 0
while count < M:
    mindex = a.index(min(a))
    buycount = min(b[mindex], M - count)
    count += buycount
    ans += a[mindex]*buycount
    a[mindex] = INF
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
ans = 0
drink = M
a, b = [], []
INF = float('inf')
for n in range(N):
    a.append(list(map(int, input().split())))
a.sort()
for i in a:
    if drink > i[1]:
        ans += i[0] * i[1]
        drink -= i[1]
    else:
        ans += i[0] * drink
        break
print(ans)
### BUGGY CODE ###

#coding: utf-8

l = range(0, 1000001)
l[1] = 0
for i in range(0, 1000):
    if l[i] != 0:
        for k in range(i + i, 1000001, i):
            l[k] = 0
        continue
l = [x for x in l if x]

while True:
    l2 = map(int,raw_input().split())
    if l2 == [0,0,0]:
        break
    a = l2[0]
    d = l2[1]
    n = l2[2]
    c = 0
    while True:
        if a in l:
            c = c + 1
        if c == n:
            break
        a = a + d
    print a
        

### FIXED CODE ###

#coding: utf-8

l = range(0, 1001)
l[1] = 0
for i in range(0, 50):
    if l[i] != 0:
        for k in range(i + i, 1001, i):
            l[k] = 0
        continue
l = [x for x in l if x]
while True:
    l2 = map(int,raw_input().split())
    if l2 == [0,0,0]:
        break
    a = l2[0]
    d = l2[1]
    n = l2[2]
    c = 0
    ch = 0
    while True:
        for p in l:
            if (a != p and a % p == 0) or a == 1:#?´???°???????????????
                ch = 1
                break
        if ch == 1:
            a = a + d
            ch = 0
            continue
        c = c + 1
        if c == n:
            break
        a = a + d
    print a
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Wed Jun 13 17:57:26 2018


1 <= a,b <= N
a % b >= K　である(a, b)の個数

分かるもの
N, K


入力
5 2

出力
7


@author: Yuya
"""

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

if K > 0:
    count = 0

    for a in range(1, N+1):
        for b in range(1, a):
            if a%b >= K:
                count = count + 1
    
    count = count + int((N+1-K)*(N-K)/2)

    print(count)
else:
    print(N*N)

### FIXED CODE ###

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

if K > 0:
    count = 0

    for b in range(K+1, N+1):
        p = N // b
        r = N % b
        count = count + p*(b-K)
        if r >= K:
            count = count + r-K+1
    
    print(count)
else:
    print(N*N)
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = []
for _ in range(m):
    b, c = map(int, input().split())
    bc.append([b, c])
    
sorted_a = sorted(a)
sorted_bc = sorted(bc, key=lambda x: x[1])

que = []
for b, c in sorted_bc:
    que += [c]*b
    
c = que.pop()    
ans = 0
for x in sorted_a:
    if x < c:
        ans += c
        if que:
            c = que.pop()
        else:
            c = 0
    else:
        ans += x
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]

a.sort()
bc.sort(reverse=True, key=lambda x: x[1])
j = 0
for i in range(m):
    while j < len(a) and bc[i][0] > 0:
        if a[j] < bc[i][1]:
            a[j] = bc[i][1]
            bc[i][0] -= 1
        j += 1
print(sum(a))
### BUGGY CODE ###

R,G,B,N = map(int, input().split())

maxr=N//R
maxg=N//G
maxb=N//B

ans=0
for i in range(maxr+1):
  for j in range(maxg+1):
    for k in range(maxb+1):
      if R*i+G*j+B*k==N:
        ans+=1
print(ans)

### FIXED CODE ###

R,G,B,N = map(int, input().split())

maxr=N//R
maxg=N//G

ans=0
for r in range(maxr,-1,-1):
  for g in range(maxg,-1,-1):
    if N-(r*R+g*G)>=0:
      if (N-(r*R+g*G))%B==0:
        ans+=1
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 10**9+7

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

if S[0] == "W" or S[-2] == "W":
    print(0)
    sys.exit()

S = [0 if i == "W" else 1 for i in S]

LR = [0 for i in range(2*N)]
count0 = 1
count0_raw = 1
ans = 1
for i in range(1, 2*N):
    if LR[i-1] == 0:
        if S[i] == S[i-1]:
            LR[i] = 1
        else:
            LR[i] = 0
    else:
        if S[i] == S[i-1]:
            LR[i] = 0
        else:
            LR[i] = 1

    if LR[i] == 0:
        count0 += 1
        count0_raw += 1
    else:
        ans *= count0 % MOD
        count0 -= 1

if count0_raw != N:
    print(0)
    sys.exit()

N_k = 1
for i in range(N):
    N_k = N_k*(i+1)%MOD 

print(ans*N_k%MOD)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 10**9+7

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

if S[0] == "W" or S[-1] == "W":
    print(0)
    sys.exit()

LR = [0 for i in range(2*N)]
count0 = 1
count0_raw = 1
ans = 1
for i in range(1, 2*N):
    if LR[i-1] == 0:
        if S[i] == S[i-1]:
            LR[i] = 1
        else:
            LR[i] = 0
    else:
        if S[i] == S[i-1]:
            LR[i] = 0
        else:
            LR[i] = 1

    if LR[i] == 0:
        count0 += 1
        count0_raw += 1
    else:
        ans *= count0
        ans %= MOD
        count0 -= 1

if count0_raw != N:
    print(0)
    sys.exit()

N_k = 1
for i in range(N):
    N_k *= i+1
    N_k %= MOD

print(ans*N_k%MOD)
### BUGGY CODE ###

from collections import Counter

n = int(input())
v = list(map(str, input().split()))

f = Counter(v[::2])
s = Counter(v[1::2])

ans = []

for i in f.keys():
    for j in s.keys():
        if i == j:
            continue
        else:
            ans.append(f[i] + s[j])

if ans:
    print(n - max(ans))
else:
    print(n // 2)

### FIXED CODE ###

from collections import Counter

n = int(input())
v = list(map(str, input().split()))

f = Counter(v[::2]).most_common(2)
s = Counter(v[1::2]).most_common(2)

if f[0][0] != s[0][0]:
    print(n - f[0][1] - s[0][1])
else:
    if len(f) == 1 or len(s) == 1:
        print(n // 2)
    else:
        print(n - max(f[0][1] + s[1][1], f[1][1] + s[0][1]))
### BUGGY CODE ###

N,K=map(int,input().split())
ans=0

A=list(map(int,input().split()))
for j in range(N):
    A[j] %= K
ans += A.count(1)

B=[]
for j in range(N-1):
    B.append((A[j]+A[j+1])%K)
ans += B.count(2)

for i in range(2,N):
    C=[]
    for j in range(N-i):
        C.append((B[j]+B[j+1]-A[j+1])%K)
    ans += C.count(i+1)
    A = B
    B = C
    
print(ans)

### FIXED CODE ###

import numpy
N,K=map(int,input().split())

if K==1:
    print(0)
    exit(0)

A=list(map(int,input().split()))
S=[0]+list(numpy.cumsum(A)) #累積和
S2=[(S[i]-i)%K for i in range(N+1)]

d = {}
ans = 0
for j in range(1,N+1):
    if j>K-1:
        if S2[j-K] in d:
            d[S2[j-K]] -= 1
        
    if S2[j-1] in d:
        d[S2[j-1]] += 1
    else:
        d[S2[j-1]] = 1
        
    if S2[j] in d:
        ans += d[S2[j]]
print(ans)
### BUGGY CODE ###

import itertools

N, M, Q = map(int, input().split())

Q_list = []
for _ in range(Q):
    q = list(map(int, input().split()))
    Q_list.append(q)

A_list = []
for a in itertools.combinations_with_replacement(range(1, M+1), N):
    A_list.append(a)

answer = 0
score_list = []
for A in A_list:
    score = 0
    for i in range(Q):
        a, b, c, d = Q_list[i][0], Q_list[i][1], Q_list[i][2], Q_list[i][3]
        a -=1
        b -=1
        if A[b] - A[a] == c:
            score += d
    answer = max(answer, score)

print(answer)

### FIXED CODE ###

import itertools

N, M, Q = map(int, input().split())

Q_list = []
for _ in range(Q):
    a, b, c, d = list(map(int, input().split()))
    Q_list.append((a, b, c, d))

A_list = []
for a in itertools.combinations_with_replacement(range(1, M+1), N):
    A_list.append(a)

answer = 0
score_list = []
for A in A_list:
    score = 0
    for i in range(Q):
        a, b, c, d = Q_list[i]
        a -=1
        b -=1
        if A[b] - A[a] == c:
            score += d
    answer = max(answer, score)

print(answer)
### BUGGY CODE ###

n = int(input())
a = {}
for i in range(n):
    s = int(input())
    if s not in a.keys():
        a[s] = 1
    elif s in a.keys():
        if a[s] == 1:
            a[s] = 0
        else:
            a[s] = 1
print(sum(a.values()))


### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
    s = int(input())
    a.append(s)
a.sort()
i = 0
cnt = 0
while i < n:
    j = i+1
    chk = 1
    if j >= n:
        cnt += 1 
        break
    while a[i] == a[j]:
        chk += 1
        j += 1
        if j >= n:
            break
    if chk%2 == 1:
        cnt += 1 
    i = j
print(cnt)
### BUGGY CODE ###

from itertools import permutations
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
A = []
B = []
C = []
D = [[] for _ in range(N)]
inf = float("inf")
for i in range(N):
    for j in range(N):
        if i == j:
            D[i].append(0)
        else:
            D[i].append(inf)


for _ in range(M):
    a, b, c = map(int, input().split())
    D[a - 1][b - 1] = c
    D[b - 1][a - 1] = c


def WarshallFloyd(D, N):
    for k in range(N):
        for i in range(N):
            for j in range(i, N):
                D[i][j] = min(D[i][j], D[i][k] + D[k][j])
                D[j][i] = D[i][j]
    return D


p = list(permutations(r))
D = WarshallFloyd(D, N)
Min = inf
for e in p:
    s = 0
    for i in range(R - 1):
        s += D[e[i] - 1][e[i + 1] - 1]
        if s > Min:
            break
    Min = min(s, Min)

print(Min)


### FIXED CODE ###

from itertools import permutations
import heapq
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
D = [[] for _ in range(N)]
inf = float("inf")
for i in range(N):
    for j in range(N):
        if i == j:
            D[i].append(0)
        else:
            D[i].append(inf)

for _ in range(M):
    a, b, c = map(int, input().split())
    D[a - 1][b - 1] = c
    D[b - 1][a - 1] = c


def WarshallFloyd(D):
    """
    >>> WarshallFloyd([[0, 1, 4], [1, 0, 1], [4, 1, 0]])
    [[0, 1, 2], [1, 0, 1], [2, 1, 0]]
    """
    for k in range(len(D)):
        for i in range(len(D)):
            for j in range(len(D)):
                D[i][j] = min(D[i][j], D[i][k] + D[k][j])
    return D


def _dijkstra(D, s, F):
    q = []
    heapq.heappush(q, (0, s))
    while len(q) != 0:
        cost, index = heapq.heappop(q)
        if F[s][index] < cost:
            continue
        for i in range(len(D)):
            if cost + D[index][i] < F[s][i]:
                F[s][i] = cost + D[index][i]
                heapq.heappush(q, (F[s][i], i))
    return F


def Dijkstra(D):
    F = [[inf] * len(D) for _ in range(len(D))]
    for i in range(len(D)):
        F[i][i] = 0
        F = _dijkstra(D, i, F)
    return F


#W = WarshallFloyd(D)
D = Dijkstra(D)
# print(W)
# print(D)
Min = inf
for e in permutations(r):
    s = 0
    for i in range(R - 1):
        s += D[e[i] - 1][e[i + 1] - 1]
    Min = min(s, Min)

print(Min)
### BUGGY CODE ###

from collections import deque

n,m,k= map(int, input().split())

fri = [[] for _ in range(n+1)]
blo = [[] for _ in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    fri[a].append(b)
    fri[b].append(a)

for i in range(k):
    a, b = map(int, input().split())
    blo[a].append(b)
    blo[b].append(a)


gru = [-1] * (n+1)
gru[0] = 0
visited = [False]*(n+1)
D = {}

for root in range(1,n+1):
    if visited[root]:
        continue
    
    D[root]= set([root])
    d = deque()
    d.append(root)
    while d:
        v = d.popleft()
        visited[v] = True
        gru[v] = root
        for to in fri[v]:
            if visited[to]:
                continue
            D[root].add(to)
            d.append(to)


for i in range(1,n+1):
    g = D[gru[i]]
    ans = len(g)-len(fri[i])-1
    for b in blo[i]:
        if b in g:
            ans -= 1
    print(ans)

### FIXED CODE ###

from collections import deque

n,m,k= map(int, input().split())

fri = [[] for _ in range(n+1)]
blo = [[] for _ in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    fri[a].append(b)
    fri[b].append(a)

for i in range(k):
    a, b = map(int, input().split())
    blo[a].append(b)
    blo[b].append(a)


gru = [-1] * (n+1)
gru[0] = 0
visited = [False]*(n+1)
D = {}

for root in range(1,n+1):
    if visited[root]:
        continue
    
    D[root]= set([root])
    d = deque()
    d.append(root)
    while d:
        v = d.popleft()
        visited[v] = True
        gru[v] = root
        for to in fri[v]:
            if visited[to]:
                continue
            D[root].add(to)
            d.append(to)


nans = [0]*n
for i in range(1,n+1):
    g = D[gru[i]]
    ans = len(g)-len(fri[i])-1
    for b in blo[i]:
        if b in g:
            ans -= 1
    nans[i-1] = ans

print(*nans, sep='\n')
### BUGGY CODE ###

n = int(input())
if n <= 2:
    print(n)
if n == 3:
    print(1)
    print(2)
    exit()

num = 0
for i in range(1,n):
    if i*(i+1)//2 >= n:
        num = i
        break
#print(num)
if num*(num+1)//2== n:
    for i in range(1,num+1):
        print(i)
    exit()
s = []
sum1 = 0
while sum1 <=n:
    sum1 +=num
    s.append(num)
    num -=1

if sum1 > n:
    s[-1] -=sum1-n
if s[-1] == 0:
    s.pop()
    
for i in range(len(s)):
    print(s[i])

### FIXED CODE ###

n = int(input())
num = 0
for k in range(1,n+1):
    #print(k)
    if k*(k+1) >=2*n:
        break
if k*(k+1) == 2*n:
    for i in range(k):
        print(i+1)
else:
    num = k*(k+1)//2-n
    #print(num,k*(k+1)//2)
    for i in range(k):
        if i+1 == num:
            continue
        else:
            print(i+1)
### BUGGY CODE ###

import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
Q = int(input())
for _ in range(Q):
    b, c = list(map(int, input().split()))
    A[np.where(A==b)] = c
    A = np.sort(A)
    print(np.sum(A))

### FIXED CODE ###

import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
D = np.zeros((10**5)+1)
S = sum(A)
for i in range(len(A)):
    D[A[i]] += 1
Q = int(input())
for _ in range(Q):
    b, c = list(map(int, input().split()))
    S += D[b]*(c-b)
    D[c] += D[b]
    D[b] = 0
    print(int(S))
### BUGGY CODE ###

S = input()
N = len(S)
i = 0
T = ""
while i <= N-2:
    if S[i] == 'B' and S[i+1] == 'C':
        T += 'D'
        i += 1
    else:
        T += S[i]
    i += 1


N = len(T)
ans = 0
l = 0
while l < N:

    if T[l] == 'B' or T[l] == 'C':
        l += 1
        continue
    
    r = l
    tmp = ''
    while r < N and (T[r] == 'A' or T[r] == 'D'):
        tmp += T[r]
        r += 1
    
    M = len(tmp)
    D_count = [0]*(M+1)
    for i in range(M-1, -1, -1):
        D_count[i] = D_count[i+1]
        if tmp[i] == 'D':
            D_count[i] += 1
    
    for i in range(M):
        if T[i] == 'A':
            ans += D_count[i]
    
    if r == N:
        break
    else:
        l = r+1

print(ans)





### FIXED CODE ###

S = input()
N = len(S)
i = 0
T = []
while i <= N-2:
    if S[i] == 'B' and S[i+1] == 'C':
        T.append('D')
        i += 1
    else:
        T.append(S[i])
    i += 1

T = "".join(T)

N = len(T)
ans = 0
l = 0
while l < N:

    if T[l] == 'B' or T[l] == 'C':
        l += 1
        continue
    
    r = l
    tmp = []
    while r < N and (T[r] == 'A' or T[r] == 'D'):
        tmp.append(T[r])
        r += 1
    
    M = len(tmp)
    D_count = [0]*(M+1)
    for i in range(M-1, -1, -1):
        D_count[i] = D_count[i+1]
        if tmp[i] == 'D':
            D_count[i] += 1
    
    for i in range(M):
        if tmp[i] == 'A':
            ans += D_count[i]
    
    if r == N:
        break
    else:
        l = r+1

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

import heapq
N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
A.sort(reverse=True)
F.sort()

if sum(A) <= K:
  print("0")
  exit(0)

L = []
for i in range(N):
  heapq.heappush(L, (-A[i]*F[i],A[i],F[i]))

for i in range(K):
  temp = heapq.heappop(L)
  rep = (-(temp[1]-1)*temp[2], (temp[1]-1), temp[2])
  heapq.heappush(L, rep)
ans = heapq.heappop(L)
print(-1*ans[0])

### FIXED CODE ###

def solve(B,G,x):
  sums = 0
  for i in range(N):
    req = B[i] - x//G[i] 
    sums += max(0,req)
  if sums <= K:
    return True
  else:
    return False

N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
A.sort(reverse=True)
F.sort()

if sum(A) <= K:
  print("0")
  exit(0)

L = []
MAX = 0
for i in range(N):
  temp = A[i]*F[i]
  MAX = max(MAX,temp)
ng = 1
ok = MAX+1
while abs(ng-ok) > 1:
  mid = (ok+ng)//2
  #print(mid,solve(A,F,mid))
  if solve(A,F,mid):
    ok = mid
  else:
    ng = mid
print(ok)
### BUGGY CODE ###

import collections


m = int(input())
a = list(map(int,input().split()))[:m]
c = collections.Counter(a)

memo = {}
rmemo = {}

for i in a:
    if rmemo.get(i):
        print(rmemo[i])
        continue

    res = 0
    for k,v in c.items():
        if i == k: v -= 1
        
        if v >= 2:
            if not memo.get(v):
                memo[v] = int((v * (v-1)/2))

            res += memo[v]

    rmemo[i] = res
    print(res)

### FIXED CODE ###

import collections


m = int(input())
A = list(map(int,input().split()))[:m]
c = collections.Counter(A)
 
def hoge(n):
    return n * (n - 1) // 2

full = sum([ hoge(i) for i in c.values()])

for a in A:
    print(full - hoge(c[a]) + hoge(c[a]-1))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

MOD = 10**9+7
N, M = map(int, input().split())
S = list(input().split())
T = list(input().split())

# Sのi文字目までと、Tのj文字目までで、dp[i][j]こ
dp = [[0]*(M+1) for _ in range(N+1)]

for r in range(1, N+1):
    for k in range(1, M+1):
        if S[r-1] == T[k-1]:
            dp[r][k] = 1+dp[r-1][k]+dp[r][k-1]
            dp[r][k] %= MOD
        else:
            dp[r][k] = dp[r-1][k]+dp[r][k-1]-dp[r-1][k-1]
            dp[r][k] %= MOD
print((dp[-1][-1]+1) % MOD)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

MOD = 10**9+7
N, M = map(int, input().split())
S = list(input().split())
T = list(input().split())

# Sのi文字目までと、Tのj文字目までで、dp[i][j]こ
dp = [[0]*(M+1) for _ in range(N+1)]

for r in range(1, N+1):
    for k in range(1, M+1):
        if S[r-1] == T[k-1]:
            dp[r][k] = 1+dp[r-1][k]+dp[r][k-1]
            dp[r][k] %= MOD
        else:
            dp[r][k] = dp[r-1][k]+dp[r][k-1]-dp[r-1][k-1]
            dp[r][k] %= MOD
print((dp[-1][-1]+1) % MOD)
### BUGGY CODE ###

a, b, c, k = map(int, input().split())
box = []
result = 0

if c == 0:
    if a >= k:
        print(k)
    else:
        print(a)
    quit()

for i in range(a):
    box.append(1)
for i in range(b):
    box.append(0)
for i in range(c):
    box.append(-1)

for i in range(k):
    result = result + box[i]

print(result)

### FIXED CODE ###

a, b, c, k = map(int, input().split())
box = []
result = 0

if k <= a:
    print(k)
    quit()
else:
    k = k - a
    result = a
    if k <= b:
        print(result)
        quit()
    else:
        k = k - b
        if k <= c:
            result = result - k
            print(result)
            quit()
        else:
            result = result -c
            print(result)
            quit()
### BUGGY CODE ###

N = int(input())

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

x = set(a)

res = 0

for i in x:
    if (a.count(i) >= i):res += (a.count(i) - i)
    else:res += a.count(i)

print(res)

### FIXED CODE ###

from collections import Counter

N = int(input())

a = list(map(int,input().split()))
c = Counter(a)

x = set(a)


res = 0
for k,v in c.items():
    if k <= 100000:
        if (v >= k):res += (v - k)
        else:res += v
    else:
        res+=v


print(res)
#
#
#for i in a:
#    if i > 100000:
#        res+=1
#
#for i in x:
#    if (a.count(i) >= i):res += (a.count(i) - i)
#    else:res += a.count(i)
#
#print(res)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
cost = [0]
for p in a:
	cost.append(cost[-1] + p)
def get_cost(l, r):
	return cost[r+1] - cost[l]

dp = [[float("inf") for _ in range(n)] for _ in range(n)]
for i, p in enumerate(a):
	dp[i][i] = 0

for g in range(1, n):
	for l in range(n-g):
		r = l + g
		for m in range(l, r):
			dp[l][r] = min(dp[l][r], dp[l][m] + dp[m+1][r] + get_cost(l, r))

print(dp[0][n-1])

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
cost = [0]
for p in a:
	cost.append(cost[-1] + p)
def get_cost(l, r):
	return cost[r+1] - cost[l]

dp = [[float("inf") for _ in range(n)] for _ in range(n)]
for i, p in enumerate(a):
	dp[i][i] = 0

for g in range(1, n):
	for l in range(n-g):
		r = l + g
		for m in range(l, r):
			dp[l][r] = min(dp[l][r], dp[l][m] + dp[m+1][r] + get_cost(l, r))

#print(dp)
print(dp[0][n-1])
### BUGGY CODE ###

import itertools

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

cnt = 0
for c in itertools.combinations(s, 2):
    l1 = list(c[0])
    l1.sort()
    l2 = list(c[1])
    l2.sort()
    if l1 == l2:
        cnt += 1
print(cnt)

### FIXED CODE ###

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


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

for i, s_i in enumerate(s):
    s_l = list(s_i)
    s_l.sort()
    a = ""
    for c in s_l:
        a += c
    s[i] = a

cnt = 0
count_dict = {}
for j in range(N):
    count_dict[s[j]] = 0
for k in range(N):
    count_dict[s[k]] += 1

for v in count_dict.values():
    if v >= 2:
        # cnt += int(factorial(v)) / int(factorial(2)) / int(factorial(v - 2))
        cnt += cmb(v, 2)

print(cnt)
### BUGGY CODE ###

a,b,k = map(int, input().split())
set0 = set(a+h for h in range(b-a+1))
setA = set(a+i for i in range(k))
setB = set(b-j for j in range(k))
l = list(set0&(setA|setB))
l.sort()
for k in l:
  print(k)

### FIXED CODE ###

a,b,k = map(int, input().split())
setA = set(i for i in range(a,min(a+k,b+1)))
setB = set(j for j in range(b,max(b-k,a-1),-1))
l = list(setA|setB)
l.sort()
for m in l:
  print(m)