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

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

l = []
for i in range(N-1):
	x = sum(a[:i+1])
	y = sum(a) - x
	l.append(abs(x-y))

print(min(l))

### FIXED CODE ###

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

X = sum(a)
x = 0
ans = 10**100

for i in range(N-1):
	x += a[i]
	ans = min(ans,abs(X - 2 * x))
    
print(ans)
### BUGGY CODE ###

import numpy as np
N, M = [int(a) for a in input().split()]

A = []
B = []

for _ in range(N):
    a, b = input().split()
    A.append(int(a))
    B.append(int(b))

used_ind = []
sum = 0

for remained_days in range(M+1):
    max_B = 0
    max_ind = -1

    for i in range(N):
        if i in used_ind:
            continue
        if A[i] > remained_days:
            continue
        if B[i] > max_B:
            max_ind = i
            max_B = B[i]
    remained_days -= A[max_ind]
    sum += max_B
    used_ind.append(max_ind)

print(sum)

### FIXED CODE ###

import heapq
import numpy as np

N, M = [int(a) for a in input().split()]

jobs = [[] for _ in range(M)]

for _ in range(N):
    a, b = map(lambda x: int(x), input().split())
    if a > M:
      continue
    jobs[M-a].append(b)

heap = []
ans = 0
for i in range(M-1, -1, -1):
    for b in jobs[i]:
        # 降順にするためにマイナスをつけて入れる
        heapq.heappush(heap, -b)
    if len(heap) != 0:
        # 取り出した値にマイナスをつけて元に戻す
        ans += -heapq.heappop(heap)
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
A = input().split()
A = [int(a) for a in A]
S = []
a = 1
number = 0
for _ in range(N + 1):
    b = A[a - 1]
    if b in S:
        c = S.index(b)
        break
    number += 1
    S.append(b)
    a = b
T = S[c:number]
if K <= N:
    print(S[K - 1])
else:
    z = K - c - 1
    y = z % (number - c)
    print(T[y])


### FIXED CODE ###

N, K = map(int, input().split())
A = input().split()
A = [int(a) for a in A]
S = [1]
a = 1
number = 0
numbers=[-1 for _ in range(N)]
for _ in range(N + 1):
    b = A[a - 1]
    if numbers[b-1] != -1:
      c=numbers[b-1]
      break
    numbers[b-1]=number
    number += 1
    S.append(b)
    a = b
T = S[c+1:number+1]
if K <= number:
  print(S[K ])
else:
  z = K - c-1
  y = z % (number - c)
  print(T[y])
### BUGGY CODE ###

def ABC073D():
    N, M, R = map(int, input().split())
    r = list(map(int, input().split()))
    ABC = [list(map(int, input().split())) for i in range(M)]
    root = [[1000000000 for i in range(N)] for j in range(N)]
    for i, j, k in ABC:
        root[i - 1][j - 1] = k
        root[j - 1][i - 1] = k

    import itertools
    def kumiawase(list_name):  # list_name(リスト)のすべての並び替え
        return itertools.permutations(list_name)

    for i in range(N):
        for j in range(N):
            for k in range(N):
                if root[i][j] > root[i][k] + root[k][j]:
                    root[i][j] = root[i][k] + root[k][j]
    for i in range(N - 1, -1, -1):
        for j in range(N - 1, -1, -1):
            for k in range(N - 1, -1, -1):
                if root[i][j] > root[i][k] + root[k][j]:
                    root[i][j] = root[i][k] + root[k][j]    
    a = kumiawase(r)
    ans = float("inf")
    for i in a:
        key = 0
        for j in range(len(i) - 1):
            key += root[i[j] - 1][i[j + 1] - 1]
        if ans > key:
            ans = int(key)
    #print(root)
    print(ans)
ABC073D()

### FIXED CODE ###

def ABC073D():
    N, M, R = map(int, input().split())
    r = list(map(int, input().split()))
    ABC = [list(map(int, input().split())) for i in range(M)]
    root = [[1000000000 for i in range(N)] for j in range(N)]
    for i, j, k in ABC:
        root[i - 1][j - 1] = k
        root[j - 1][i - 1] = k

    import itertools
    def kumiawase(list_name):  # list_name(リスト)のすべての並び替え
        return itertools.permutations(list_name)


    from scipy.sparse import csgraph
    root = csgraph.floyd_warshall(root)

    a = kumiawase(r)
    ans = float("inf")
    for i in a:
        key = 0
        for j in range(len(i) - 1):
            key += root[i[j] - 1][i[j + 1] - 1]
        if ans > key:
            ans = int(key)
    #print(root)
    print(ans)
ABC073D()
### BUGGY CODE ###

import sys
readline = sys.stdin.readline
N = int(readline())

testimonies = {}
for i in range(N):
    A = int(readline())
    testimonies[i] = [[], []]
    for _ in range(A):
        x, y = map(int, readline().rstrip().split())
        testimonies[i][y].append(x-1)

def check(honest_persons):
    """矛盾がないか検証する"""
    honest_checked = []  # 宛先を確認済みの正直者の人
    honest_stack = honest_persons[:]  # 宛先を確認する正直者の人の待ち行列
    honest, liers = honest_persons[:], []  # 正直者の人, 不親切な人

    # 正直者の人の証言も元に、正直者の人/不親切な人を追加していく
    while len(honest_stack) > 0:
        honest_person = honest_stack.pop(0)
        honest_checked.append(honest_person)
        next_honest_persons = testimonies[honest_person][1]

        # 検証済み以外の人をstackする
        for person in next_honest_persons:
            if person not in honest_checked:
                honest_stack.append(person)

        honest += testimonies[honest_person][1]
        liers += testimonies[honest_person][0]

    # 矛盾がなければOK
    if len(set(honest) & set(liers)) == 0:
        return True
    else:
        return False

def main():
    # bit全探索する
    ans = 0
    for i in range(1, 2**N):
        comb = bin(i)[2:].zfill(N)
        honest_persons = []
        for p, c in enumerate(comb):
            if c == '1':
                honest_persons.append(p)
        if check(honest_persons):
            ans = max(ans, sum(list(map(int, list(comb)))))

    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
N = int(sys.stdin.readline())

testimonies = [[-1 for _ in range(N)] for _ in range(N)]
for i in range(N):
    A = int(sys.stdin.readline())
    for _ in range(A):
        x, y = map(int, sys.stdin.readline().rstrip().split())
        testimonies[i][x-1] = y

def check(honest_persons):
    flag = True
    for i in range(N):
        if honest_persons[i]:
            for j in range(N):
                if testimonies[i][j] == -1:
                    continue
                if testimonies[i][j] != honest_persons[j]:
                    flag = False
                    break
    return flag

def main():
    ans = 0
    for i in range(1, 2**N):
        honest_persons = bin(i)[2:].zfill(N)
        honest_persons = list(map(int, list(honest_persons)))

        if check(honest_persons):
            ans = max(ans, sum(honest_persons))

    print(ans)

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

import sys
from fractions import gcd
input = sys.stdin.readline

def lcm(x, y):
    return (x * y) // gcd(x, y)
def main():
    n = int(sys.stdin.readline())
    a = list(map(int,input().split()))
    
    l = a[0]
    for i in range(n):
        l = lcm(l, a[i])
    sum = 0
    for i in range(n):
        sum += l // a[i]
    print(sum % 1000000007)
main()

### FIXED CODE ###

import sys
from fractions import gcd
input = sys.stdin.readline

def lcm(x, y):
    return (x * y) // gcd(x, y)
def main():
    n = int(sys.stdin.readline())
    a = list(map(int,input().split()))
    
    l = a[0]
    for i in range(n):
        l = lcm(l, a[i])
    sum = 0
    for i in range(n):
        sum += l // a[i]
    print(sum % 1000000007)
main()
### BUGGY CODE ###

import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
from functools import lru_cache
INF = 1 << 60

#ここから書き始める
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
x = [(0, 0)] * m
for i in range(m):
    b, c = map(int, input().split())
    x[i] = (c, b)
x.sort(reverse=True)
for b, c in x:
    a.extend([b] * c)
a.sort(reverse=True)
# print(a)
print(sum(a[:n]))



### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int,input().split())) for i in range(m)]
bc.sort(key=lambda x:x[1], reverse=True)
  
for b,c in bc:
  a.extend([c]*b)
  if len(a) > n*2:
    break
a.sort(reverse=True)
print(sum(a[:n]))
### BUGGY CODE ###

n, k = map(int, input().split())
h = [int(x) for x in input().split()]

INF = 10**10
dp = [INF]*(n+k+1)
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(0, n+1):
    for j in range(1, k+1):
        if i+j < n:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]))
print(dp[n-1])



### FIXED CODE ###

n,k = map(int ,input().split(" "))
h = [int(x) for x in input().split(" ")]
INF = 10**9
dp = [INF] * n
dp[0] = 0

for i in range(1,n):
    h_i = h[i]
    s = i-k if i-k > 0 else 0
    dp[i] = min(d_j + abs(h_i - h_j)for d_j, h_j in zip(dp[s:i], h[s:i]))

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

h,w = map(int,input().split())

matrix = [[1]*(w+2)]
matrix += [[1] + [x == '#' for x in input().rstrip()] + [1] for _ in range(h)]
matrix.append([1]*(w+2))

matrix_list1 = []

cnt = -1

for i in range(1,h+1):
    for j in range(1,w+1):
        if matrix[i][j]:
            matrix_list1.append((i,j))

while matrix_list1:
    matrix_list2 = []
    for x,y in matrix_list1:
        if not matrix[x+1][y]:
            matrix[x+1][y] = 1
            matrix_list2.append((x+1,y))
        if not matrix[x-1][y]:
            matrix[x-1][y] = 1
            matrix_list2.append((x-1,y))
        if not matrix[x][y+1]:
            matrix[x][y+1] = 1
            matrix_list2.append((x,y+1))
        if not matrix[x][y-1]:
            matrix[x][y-1] = 1
            matrix_list2.append((x,y-1))
    matrix_list1 = matrix_list2
    cnt += 1
    
print(cnt)

### FIXED CODE ###

from collections import deque

h,w = map(int,input().split())
matrix = [["a" for _ in range(w+2)]] + [list("a" + input() + "a") for _ in range(h)] + [["a" for _ in range(w+2)]]

matrix_list1 = deque()
cnt = 0

for i in range(1,h+1):
    for j in range(1,w+1):
        if matrix[i][j] == "#":
            matrix_list1.append([i,j])

while len(matrix_list1) != 0:     
    for _ in range(len(matrix_list1)):
        x,y = matrix_list1.popleft()
        if matrix[x+1][y] == ".":
            matrix[x+1][y] = "#"
            matrix_list1.append([x+1,y])
        if matrix[x-1][y] == ".":
            matrix[x-1][y] = "#"
            matrix_list1.append([x-1,y])
        if matrix[x][y+1] == ".":
            matrix[x][y+1] = "#"
            matrix_list1.append([x,y+1])
        if matrix[x][y-1] == ".":
            matrix[x][y-1] = "#"
            matrix_list1.append([x,y-1])
    else:
        if len(matrix_list1) > 0:
            cnt += 1
    
print(cnt)
### BUGGY CODE ###

from sys import stdin
from itertools import accumulate

def solve():
    file_input = stdin
    
    N = int(file_input.readline())
    img = tuple(tuple(map(int, line.split())) for line in file_input)
    
    acc_row = (tuple(accumulate(line)) + (0,) for line in img)
    acc_col = tuple(tuple(accumulate(line)) + (0,) for line in zip(*img))
    
    ans = 0
    for i, tpl_1 in enumerate(zip(img, acc_row)):
        img_i, acc_row_i = tpl_1
        for j, img_j in enumerate(img[i:], start=i):
            if acc_row_i[j] - acc_row_i[i - 1] > ans:
                ans = acc_row_i[j] - acc_row_i[i - 1]
                
            if i == j:
                continue
            
            col = acc_col[0]
            col_max = col[j] - col[i - 1]
            
            for acc_col_k, img_i_k, img_j_k in zip(acc_col[1:], img_i[1:], img_j[1:]):
                col = acc_col_k[j] - acc_col_k[i - 1]
                
                if col_max > 0:
                    c_ans = col_max + col
                    if c_ans > ans:
                        ans = c_ans
                else:
                    if col > ans:
                        ans = col
                
                t_col_max = col_max + img_i_k + img_j_k
                if t_col_max > col:
                    col_max = t_col_max
                else:
                    col_max = col
    print(ans)

solve()


### FIXED CODE ###

from sys import stdin
from itertools import accumulate

def solve():
    file_input = stdin
    
    N = int(file_input.readline())
    G = tuple(tuple(map(int, line.split())) for line in file_input)
    G1 = tuple(t[1:] for t in G)
    
    # accumulated rows
    ar = ((0,) + tuple(accumulate(line)) for line in G)
    
    # accumulated columns
    ac = ((0,) + tuple(accumulate(line)) for line in zip(*G))
    ac_1 = next(ac)
    ac = tuple(zip(*ac))
    
    ans = 0
    for i, t1 in enumerate(zip(G1, ar, ac, ac_1)):
        G_i, ar_i, ac_i, ac_1i = t1
        ar_ii = ar_i[i]
        for j, t2 in enumerate(zip(G1[i:], ar_i[i+1:], ac[i+1:], ac_1[i+1:]), start=i):
            G_j, ar_ij, ac_j, ac_1j = t2
            single_row = ar_ij - ar_ii
            if single_row > ans:
                ans = single_row
                
            if i == j:
                continue
            
            col_max = ac_1j - ac_1i
            
            for ac_jk, ac_ik, G_ik, G_jk in zip(ac_j, ac_i, G_i, G_j):
                col = ac_jk - ac_ik
                
                if col_max > 0:
                    c_ans = col_max + col
                    if c_ans > ans:
                        ans = c_ans
                else:
                    if col > ans:
                        ans = col
                
                t_col_max = col_max + G_ik + G_jk
                if t_col_max > col:
                    col_max = t_col_max
                else:
                    col_max = col
    print(ans)

solve()
### BUGGY CODE ###

import itertools

n = int(input())
sin = [''.join(sorted(input())) for _ in range(n)]

ans = []
combi =[]

for i in set(sin):
    if sin.count(i)  > 1:
        combi.append(sin.count(i))

for j in combi:
    x = list(itertools.combinations(range(j), 2))
    ans.append(len(x))

print(sum(ans))


### FIXED CODE ###

from collections import Counter

n = int(input())
sin = [''.join(sorted(input())) for _ in range(n)]

ans = 0

for i in Counter(sin).values():
    ans += i*(i-1) //2
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
cand_path = [tuple(map(int, input().split())) for _ in range(m)]

ans = 'IMPOSSIBLE'

for i in range(2, n):
  path = [1, i, n]
  if len([True for x in zip(path, path[1:]) if x in cand_path])==2:
    ans = 'POSSIBLE'
    break
    
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
all_cand = [tuple(map(int, input().split())) for _ in range(m)]

start_path_end = set([path[1] for path in all_cand if path[0]==1])
end_path_start = set([path[0] for path in all_cand if path[1]==n])

print('POSSIBLE' if start_path_end&end_path_start else 'IMPOSSIBLE')
### BUGGY CODE ###

n = int(input())
lst = [int(input()) for i in range(n)]
for i in range(n):
  tmp = lst[:]
  del tmp[i]
  print(max(tmp))


### FIXED CODE ###

n = int(input())
lst = [int(input()) for i in range(n)]
m = max(lst)
tmp = lst[:]
del tmp[tmp.index(max(tmp))]
s = max(tmp)
if lst.count(m) > 1:
  for i in range(n):
    print(m)
else:
  for i in range(n):
    if lst[i]==m:
      print(s)
    else:
      print(m)
### BUGGY CODE ###

digits = int(input())
num_list = [int(i) for i in list(input())]
flag1 = 0
flag2 = 0
counter = 0


for num1 in range(10):
	for num2 in range(10):
		for num3 in range(10):
			flag1 = 0
			flag2 = 0
			for digit in range(digits):
				if flag1 == 0 and flag2 == 0 and num1 == num_list[digit]:
					flag1 = 1
					continue
				if flag1 == 1 and num2 == num_list[digit]:
					flag2 = 1
					flag1 = 0
					continue
				if flag2 == 1 and num3 == num_list[digit]:
					counter += 1
					flag2 = 0
					break
print(counter)



### FIXED CODE ###

digits = int(input())
num_list = [int(i) for i in list(input())]
flag1 = 0
flag2 = 0
counter = 0


for num1 in range(10):
	for num2 in range(10):
		for num3 in range(10):
			flag1 = 0
			flag2 = 0
			for digit in range(digits):
				if flag1 == 0 and flag2 == 0 and num1 == num_list[digit]:
					flag1 = 1
					continue
				if flag1 == 1 and num2 == num_list[digit]:
					flag2 = 1
					flag1 = 0
					continue
				if flag2 == 1 and num3 == num_list[digit]:
					counter += 1
					flag2 = 0
					break
print(counter)
### BUGGY CODE ###

def resolve():
    n,k,q=map(int, input().split())
    a=k-q
    l=[int(input()) for i in range(q)]
    for i in range(1,n+1):
        if a+l.count(i)>0:
            print('Yes')
        else:
            print('No')
resolve()

### FIXED CODE ###

def resolve():
    n,k,q=map(int, input().split())
    l=[int(input()) for i in range(q)]
    a=[k-q for i in range(n)]
    for i in l:
        a[i-1]+=1
    for i in range(n):
        if a[i]<=0:
            print('No')
        else:
            print('Yes')
resolve()
### BUGGY CODE ###

n = int(input())
s = input()
ans = n
for i in range(n):
	ans = min(ans, s[:i][:-1].count("W") + s[i:].count("E"))
	
print(ans)


### FIXED CODE ###

n=int(input())
s=input()
m=n+5
w=0
e=0
for i in range(1,n):
    if s[i]=='E':
        e+=1
m=min(m,w+e)
for i in range(1,n):
    if s[i-1]=='W':
        w+=1
    if s[i]=='E':
        e-=1
    m=min(m,w+e)
print(m)
### BUGGY CODE ###

import math
import itertools
from functools import reduce

def gcd(*numbers):
    def gcd(a, b):
        while b != 0:
            a, b = b, a % b
        return a
    return reduce(gcd, numbers)


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


c = itertools.combinations(A, N-1)

a_max = gcd(*A)
for i in c:
    a_max = max(a_max, gcd(*list(i)))

print(a_max)


### FIXED CODE ###

def gcd(x,y):
    if x % y == 0:
        return y
    else:
        x %= y
        return gcd(y, x)

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

l_gcd = [-1] * N
r_gcd = [-1] * N

for i in range(N):
    if i == 0:
        l_gcd [0] = blackboard[0]
    else:
        l_gcd[i] = gcd(l_gcd[i-1],blackboard[i])


for i in reversed(range(N)):
    if i == N - 1:
        r_gcd[N-1] = blackboard[N-1]
    else:
        r_gcd[i] = gcd(r_gcd[i+1],blackboard[i])


#左端と右端のときの値を予め比較しておく。
ans = max(l_gcd[-2],r_gcd[1])

for i in range(1,N-1):
    ans = max(ans,gcd(l_gcd[i-1],r_gcd[i+1]))
print(ans)
### BUGGY CODE ###

n = int(input())

class Kake:
    def __init__(self, n):
        self.n = n
        
    def div(self):
        div_dict = {}
        
        for i in range(1, int(self.n/2)+1):
            if self.n % i == 0 and i <= (self.n/i):
                div_dict[i] = int(self.n / i)

        sa_list = list()
        for i in div_dict:
            sa_list.append((i-1)+(div_dict[i]-1))
        print(min(sa_list))
        
kake = Kake(n)
kake.div()


### FIXED CODE ###

n = int(input())

class Kake:
    def __init__(self, n):
        self.n = n

    def div(self):
        div_dict = {}
        
        for i in range(1, int(self.n**0.5)+1):
            if self.n % i == 0 and i <= (self.n/i):
                div_dict[i] = int(self.n / i)     
    
        sa_list = list()
        for i in div_dict:
            sa_list.append((i-1)+(div_dict[i]-1))
        print(min(sa_list))
         
kake = Kake(n)
kake.div()
### BUGGY CODE ###

k,s = (int(_) for _ in input().split())

ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if(x+y+z == s):
                ans += 1
                
print(ans)

### FIXED CODE ###

k,s = (int(_) for _ in input().split())

ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if(0 <= z <= k):
            ans += 1

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

def main():
	N, W = map(int, input().split())
	WV = [list(map(int, input().split())) for _ in range(N)]

	dp = [0] * (W + 1)
	for w, v in WV:
		for n in range(W, w - 1, -1):
			dp[n] = max(dp[n], dp[n - w] + v)
		#for t in dp:
		#	print("{:4d}".format(t), end="")
		#print()
	return max(dp)

print(main())


### FIXED CODE ###

def dp():
  N, W = map(int, input().split())
  WV = (map(int, input().split()) for _ in range(N))

  DP = [0] * (W+1)
  for w, v in WV:
    for j in range(W, w-1, -1):
      dp = DP[j-w] + v 
      if DP[j] < dp:
        DP[j] = dp
  return max(DP)
print(dp())
### BUGGY CODE ###

stdin = input().split()
a = int(stdin[0]) # 高橋君のクッキー
b = int(stdin[1]) # 青木君のクッキー
K = int(stdin[2]) # 繰り返し回数

for turn in range(K):
  if a > 0: # 高橋君のクッキーがあった
    a -= 1
  elif b > 0: # 青木君のがあった
    b -= 1


print('{} {}'.format(a, b))

### FIXED CODE ###

stdin = input().split()
a = int(stdin[0]) # 高橋君のクッキー
b = int(stdin[1]) # 青木君のクッキー
k = int(stdin[2]) # 繰り返し回数

if a > k:
  a -= k
else:
  k -= a
  a = 0
  
  if k > b:
    b = 0
  else:
    b -= k
  
print('{} {}'.format(a, b))
### BUGGY CODE ###

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

w, v = [0]*N, [0]*N 
for _ in range(N):
    w[_], v[_] = map(int, input().split())

dp = [[0]*(W+1) for _ in range(N+1)]
    
def npsk_1(N, W):
    for i in range(N):
        for j in range(W+1):
            if j - w[i] >= 0:
                dp[i+1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])
            else:
                dp[i+1][j] = dp[i][j]
    
    print(dp[-1][-1])

npsk_1(N, W)

### FIXED CODE ###

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

w, v = [0] * N, [0] * N

for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(N):
	for j in range(W + 1):
		if j - w[i] >= 0:
			dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])
		else:
		    dp[i + 1][j] = dp[i][j] 

print(dp[N][W])
### BUGGY CODE ###

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

E = [(p+1)/2 for p in P]

M = 0
for i in range(0, N-K+1):
    exp = sum(E[i:i+K])
    if M < exp:
        M = exp

print(M)


### FIXED CODE ###

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

M = [sum(P[:K]) / 2 + K / 2]

for i in range(1, N-K+1):
    M.append(M[i-1] - P[i-1]/2 + P[i-1+K]/2)


print(max(M))
### BUGGY CODE ###

n = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(n):
    for j in range(0,i+1):
        if P[i] > P[j]:
            break
    else:
        ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
P = list(map(int,input().split()))
ans = 0
mi = P[0]
for i in range(n):
    if P[i] <= mi:
        mi = P[i]
        ans += 1
print(ans)
### BUGGY CODE ###

def mygets():
    return list(map(int, input().strip().split()))

def mymin(a, b):
    if a < b:
        return a
    else:
        return b

n, x = mygets()
a = mygets()

b1 = a.copy()
b2 = a.copy()

ans = sum(a)

for i in range(1, n):
    for j in range(n):
        b2[j] = mymin(a[j], b1[(j + n - 1) % n])
    ans = mymin(ans, sum(b2) + i * x)
    b1, b2 = b2, b1

print(ans)

### FIXED CODE ###

def mygets():
    return list(map(int, input().strip().split(' ')))

n, x = mygets()
a = mygets()

b1 = a

ans = sum(a)

def f(k, u):
    j = k - 1
    if j < 0:
        j = n - 1
    w = b1[j]
    if u < w:
        return u
    return w

for i in range(1, n):
    b2 = [f(k, u) for k, u in enumerate(a)]
    ans = min(ans, sum(b2) + i * x)
    b1 = b2

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

from bisect import bisect_left, insort_left
from collections import deque
import sys
readlines = sys.stdin.readline
def main():
	x,y,a,b,c = map(int,input().split())

	p = list(map(int,input().split()))
	q = list(map(int,input().split()))
	r = list(map(int,input().split()))

	p.sort()
	q.sort()
	r.sort(reverse=True)

	p = deque(p[a-x:])
	q = deque(q[b-y:])
	ans = sum(p) + sum(q)

	for i in range(c):
		if p[0] < r[i] and q[0] < r[i]:
			if p[0] < q[0]:
				ans -= p.popleft()
				ans += r[i]
				insort_left(list(p),r[i])
				p = deque(p)
			else:
				ans -= q.popleft()
				ans += r[i]
				insort_left(list(q),r[i])
				q = deque(q)
		elif p[0] < r[i] and q[0] >= r[i]:
			ans -= p.popleft()
			ans += r[i]
			insort_left(list(p),r[i])
			p = deque(p)
		elif p[0] >= r[i] and q[0] < r[i]:
			ans -= q.popleft()
			ans += r[i]
			insort_left(list(q),r[i])
			q = deque(q)
		else:
			break

	print(ans)
if __name__ == '__main__':
	main()

### FIXED CODE ###

x,y,a,b,c = map(int,input().split())

p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort()
q.sort()
r.sort(reverse=True)

p = p[a-x:]
q = q[b-y:]

p.extend(q)
p.sort()

ans = sum(p)
count = 0
for i in range(c):
	if p[i] < r[i]:
		ans += r[i] - p[i]
	else:
		break
print(ans)