import itertools
N, A, B, C = map(int, input().split())
ln = [int(input()) for _ in range(N)]
bit = itertools.product([0, 1, 2, 3], repeat=N)
ans = 10000
for bi in bit:
    cnt = 0
    a = []
    b = []
    c = []
    for i in range(N):
        if bi[i] == 1:
            a.append(ln[i])
        elif bi[i] == 2:
            b.append(ln[i])
        elif bi[i] == 3:
            c.append(ln[i])
    if len(a) == 0 or len(b) == 0 or len(c) == 0:
        continue
    cnt += 10*(max(len(a)-1, 0)+max(len(b)-1, 0)+max(len(c)-1, 0))
    temp = [sum(a), sum(b), sum(c)]
    temp.sort()
    cnt += abs(temp[0]-C) + abs(temp[1]-B) + abs(temp[2]-A)
    ans = min(ans, cnt)
print(ans) import itertools itertools N, A, B, C = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split A B C int(input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input ln = [int(input()) for _ in range(N)] ln [int(input()) for _ in range(N)] bit = itertools.product([0, 1, 2, 3], repeat=N) bit itertools.product([0, 1, 2, 3], repeat=N) itertools.product itertools product [0, 1, 2, 3] 0 1 2 3 repeat=N repeat N ans = 10000 ans 10000 for bi in bit:
    cnt = 0
    a = []
    b = []
    c = []
    for i in range(N):
        if bi[i] == 1:
            a.append(ln[i])
        elif bi[i] == 2:
            b.append(ln[i])
        elif bi[i] == 3:
            c.append(ln[i])
    if len(a) == 0 or len(b) == 0 or len(c) == 0:
        continue
    cnt += 10*(max(len(a)-1, 0)+max(len(b)-1, 0)+max(len(c)-1, 0))
    temp = [sum(a), sum(b), sum(c)]
    temp.sort()
    cnt += abs(temp[0]-C) + abs(temp[1]-B) + abs(temp[2]-A)
    ans = min(ans, cnt) bi bit cnt = 0 cnt 0 a = [] a [] b = [] b [] c = [] c [] for i in range(N):
        if bi[i] == 1:
            a.append(ln[i])
        elif bi[i] == 2:
            b.append(ln[i])
        elif bi[i] == 3:
            c.append(ln[i])
     i range(N) range N if bi[i] == 1:
            a.append(ln[i])
        elif bi[i] == 2:
            b.append(ln[i])
        elif bi[i] == 3:
            c.append(ln[i])
     bi[i] == 1 bi[i] bi i 1 a.append(ln[i]) a.append a append ln[i] ln i elif bi[i] == 2:
            b.append(ln[i])
         bi[i] == 2 bi[i] bi i 2 b.append(ln[i]) b.append b append ln[i] ln i elif bi[i] == 3:
            c.append(ln[i])
     bi[i] == 3 bi[i] bi i 3 c.append(ln[i]) c.append c append ln[i] ln i if len(a) == 0 or len(b) == 0 or len(c) == 0:
        continue
     len(a) == 0 or len(b) == 0 or len(c) == 0 len(a) == 0 or len(b) == 0 len(a) == 0 len(a) len a 0 len(b) == 0 len(b) len b 0 len(c) == 0 len(c) len c 0 continue cnt += 10*(max(len(a)-1, 0)+max(len(b)-1, 0)+max(len(c)-1, 0)) cnt 10*(max(len(a)-1, 0)+max(len(b)-1, 0)+max(len(c)-1, 0)) 10 max(len(a)-1, 0)+max(len(b)-1, 0)+max(len(c)-1, 0) max(len(a)-1, 0)+max(len(b)-1, 0) max(len(a)-1, 0) max len(a)-1 len(a) len a 1 0 max(len(b)-1, 0) max len(b)-1 len(b) len b 1 0 max(len(c)-1, 0) max len(c)-1 len(c) len c 1 0 temp = [sum(a), sum(b), sum(c)] temp [sum(a), sum(b), sum(c)] sum(a) sum a sum(b) sum b sum(c) sum c temp.sort() temp.sort temp sort cnt += abs(temp[0]-C) + abs(temp[1]-B) + abs(temp[2]-A) cnt abs(temp[0]-C) + abs(temp[1]-B) + abs(temp[2]-A) abs(temp[0]-C) + abs(temp[1]-B) abs(temp[0]-C) abs temp[0]-C temp[0] temp 0 C abs(temp[1]-B) abs temp[1]-B temp[1] temp 1 B abs(temp[2]-A) abs temp[2]-A temp[2] temp 2 A ans = min(ans, cnt) ans min(ans, cnt) min ans cnt print(ans) print ans bit = itertools.product([0, 1, 2, 3], repeat=N) itertools.product([0, 1, 2, 3], repeat=N) bit cnt = 0 0 cnt A, B, C = map(int, input().split()) map(int, input().split()) A N, A, B, C = map(int, input().split()) map(int, input().split()) N ans = min(ans, cnt) min(ans, cnt) ans C = map(int, input().split()) map(int, input().split()) C c = [] [] c ans = 10000 10000 ans a = [] [] a cnt += abs(temp[0]-C) + abs(temp[1]-B) + abs(temp[2]-A) abs(temp[0]-C) + abs(temp[1]-B) + abs(temp[2]-A) cnt ln = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] ln B, C = map(int, input().split()) map(int, input().split()) B b = [] [] b cnt += 10*(max(len(a)-1, 0)+max(len(b)-1, 0)+max(len(c)-1, 0)) 10*(max(len(a)-1, 0)+max(len(b)-1, 0)+max(len(c)-1, 0)) cnt temp = [sum(a), sum(b), sum(c)] [sum(a), sum(b), sum(c)] temp
import itertools
N, A, B, C = map(int, input().split())
ln = [int(input()) for _ in range(N)]
bit = itertools.product([0, 1, 2, 3], repeat=N)
ans = 10000
for bi in bit:
    cnt = 0
    a = []
    b = []
    c = []
    for i in range(N):
        if bi[i] == 1:
            a.append(ln[i])
        elif bi[i] == 2:
            b.append(ln[i])
        elif bi[i] == 3:
            c.append(ln[i])
    if len(a) == 0 or len(b) == 0 or len(c) == 0:
        continue
    cnt += 10*(max(len(a)-1, 0)+max(len(b)-1, 0)+max(len(c)-1, 0))
    temp = [sum(a), sum(b), sum(c)]
    temp.sort()
    cnt += abs(temp[0]-C) + abs(temp[1]-B) + abs(temp[2]-A)
    ans = min(ans, cnt)
print(ans)
