import itertools
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
pat = list(itertools.product([0, 1, 2, 3], repeat=n))
ans = 10**10
for p in pat:
    aa, bb, cc = 0, 0, 0
    mp = -30
    for i in range(n):
        if p[i] == 0:
            pass
        elif p[i] == 1:
            aa += l[i]
            mp += 10
        elif p[i] == 2:
            bb += l[i]
            mp += 10
        else:
            cc += l[i]
            mp += 10
    if aa == 0 or bb == 0 or cc == 0:
        continue
    abc = [aa, bb, cc]
    pat2 = list(itertools.permutations([0, 1, 2]))
    for q in pat2:
        mp2 = 0
        mp2 += abs(a - abc[q[0]])
        mp2 += abs(b - abc[q[1]])
        mp2 += abs(c - abc[q[2]])
        ans = min(ans, mp + mp2)
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 l = [int(input()) for _ in range(n)] l [int(input()) for _ in range(n)] pat = list(itertools.product([0, 1, 2, 3], repeat=n)) pat list(itertools.product([0, 1, 2, 3], repeat=n)) list 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 = 10**10 ans 10**10 10 10 for p in pat:
    aa, bb, cc = 0, 0, 0
    mp = -30
    for i in range(n):
        if p[i] == 0:
            pass
        elif p[i] == 1:
            aa += l[i]
            mp += 10
        elif p[i] == 2:
            bb += l[i]
            mp += 10
        else:
            cc += l[i]
            mp += 10
    if aa == 0 or bb == 0 or cc == 0:
        continue
    abc = [aa, bb, cc]
    pat2 = list(itertools.permutations([0, 1, 2]))
    for q in pat2:
        mp2 = 0
        mp2 += abs(a - abc[q[0]])
        mp2 += abs(b - abc[q[1]])
        mp2 += abs(c - abc[q[2]])
        ans = min(ans, mp + mp2) p pat aa, bb, cc = 0, 0, 0 aa 0 bb 0 cc 0 mp = -30 mp -30 for i in range(n):
        if p[i] == 0:
            pass
        elif p[i] == 1:
            aa += l[i]
            mp += 10
        elif p[i] == 2:
            bb += l[i]
            mp += 10
        else:
            cc += l[i]
            mp += 10
     i range(n) range n if p[i] == 0:
            pass
        elif p[i] == 1:
            aa += l[i]
            mp += 10
        elif p[i] == 2:
            bb += l[i]
            mp += 10
        else:
            cc += l[i]
            mp += 10
     p[i] == 0 p[i] p i 0 elif p[i] == 1:
            aa += l[i]
            mp += 10
         p[i] == 1 p[i] p i 1 aa += l[i] aa l[i] l i mp += 10 mp 10 elif p[i] == 2:
            bb += l[i]
            mp += 10
         p[i] == 2 p[i] p i 2 bb += l[i] bb l[i] l i mp += 10 mp 10 cc += l[i] cc l[i] l i mp += 10 mp 10 if aa == 0 or bb == 0 or cc == 0:
        continue
     aa == 0 or bb == 0 or cc == 0 aa == 0 or bb == 0 aa == 0 aa 0 bb == 0 bb 0 cc == 0 cc 0 continue abc = [aa, bb, cc] abc [aa, bb, cc] aa bb cc pat2 = list(itertools.permutations([0, 1, 2])) pat2 list(itertools.permutations([0, 1, 2])) list itertools.permutations([0, 1, 2]) itertools.permutations itertools permutations [0, 1, 2] 0 1 2 for q in pat2:
        mp2 = 0
        mp2 += abs(a - abc[q[0]])
        mp2 += abs(b - abc[q[1]])
        mp2 += abs(c - abc[q[2]])
        ans = min(ans, mp + mp2) q pat2 mp2 = 0 mp2 0 mp2 += abs(a - abc[q[0]]) mp2 abs(a - abc[q[0]]) abs a - abc[q[0]] a abc[q[0]] abc q[0] q 0 mp2 += abs(b - abc[q[1]]) mp2 abs(b - abc[q[1]]) abs b - abc[q[1]] b abc[q[1]] abc q[1] q 1 mp2 += abs(c - abc[q[2]]) mp2 abs(c - abc[q[2]]) abs c - abc[q[2]] c abc[q[2]] abc q[2] q 2 ans = min(ans, mp + mp2) ans min(ans, mp + mp2) min ans mp + mp2 mp mp2 print(ans) print ans mp += 10 10 mp b, c = map(int, input().split()) map(int, input().split()) b l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l c = map(int, input().split()) map(int, input().split()) c cc += l[i] l[i] cc a, b, c = map(int, input().split()) map(int, input().split()) a cc = 0, 0, 0 0 cc mp2 = 0 0 mp2 pat = list(itertools.product([0, 1, 2, 3], repeat=n)) list(itertools.product([0, 1, 2, 3], repeat=n)) pat ans = min(ans, mp + mp2) min(ans, mp + mp2) ans mp2 += abs(c - abc[q[2]]) abs(c - abc[q[2]]) mp2 bb += l[i] l[i] bb bb, cc = 0, 0, 0 0 bb mp = -30 -30 mp ans = 10**10 10**10 ans aa += l[i] l[i] aa mp += 10 10 mp abc = [aa, bb, cc] [aa, bb, cc] abc mp2 += abs(b - abc[q[1]]) abs(b - abc[q[1]]) mp2 pat2 = list(itertools.permutations([0, 1, 2])) list(itertools.permutations([0, 1, 2])) pat2 n, a, b, c = map(int, input().split()) map(int, input().split()) n mp2 += abs(a - abc[q[0]]) abs(a - abc[q[0]]) mp2 aa, bb, cc = 0, 0, 0 0 aa mp += 10 10 mp
import itertools
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
pat = list(itertools.product([0, 1, 2, 3], repeat=n))
ans = 10**10
for p in pat:
    aa, bb, cc = 0, 0, 0
    mp = -30
    for i in range(n):
        if p[i] == 0:
            pass
        elif p[i] == 1:
            aa += l[i]
            mp += 10
        elif p[i] == 2:
            bb += l[i]
            mp += 10
        else:
            cc += l[i]
            mp += 10
    if aa == 0 or bb == 0 or cc == 0:
        continue
    abc = [aa, bb, cc]
    pat2 = list(itertools.permutations([0, 1, 2]))
    for q in pat2:
        mp2 = 0
        mp2 += abs(a - abc[q[0]])
        mp2 += abs(b - abc[q[1]])
        mp2 += abs(c - abc[q[2]])
        ans = min(ans, mp + mp2)
print(ans)