n, a, b, c = list(map(int, input().split(' ')))
ln = [None] * n
for i in range(n):
    ln[i] = (int(input()))


def dfs(i, ap, bp, cp):
    pattern = [ap, bp, cp]
    if i >= n and [] not in pattern:
        mp = 0
        for p in pattern:
            mp += max([0, len(p) - 1]) * 10
        mp += abs(a - sum(pattern[0]))
        mp += abs(b - sum(pattern[1]))
        mp += abs(c - sum(pattern[2]))
        return mp
    elif i >= n:
        return float('inf')
    else:
        return min([
            dfs(i + 1, ap + [ln[i]], bp, cp),
            dfs(i + 1, ap, bp + [ln[i]], cp),
            dfs(i + 1, ap, bp, cp + [ln[i]]),
            dfs(i + 1, ap, bp, cp)
        ])


result = dfs(0, [], [], [])
print(result)

 n, a, b, c = list(map(int, input().split(' '))) n list(map(int, input().split(' '))) list map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' a b c ln = [None] * n ln [None] * n [None] None n for i in range(n):
    ln[i] = (int(input())) i range(n) range n ln[i] = (int(input())) ln[i] ln i int(input()) int input() input def dfs(i, ap, bp, cp):
    pattern = [ap, bp, cp]
    if i >= n and [] not in pattern:
        mp = 0
        for p in pattern:
            mp += max([0, len(p) - 1]) * 10
        mp += abs(a - sum(pattern[0]))
        mp += abs(b - sum(pattern[1]))
        mp += abs(c - sum(pattern[2]))
        return mp
    elif i >= n:
        return float('inf')
    else:
        return min([
            dfs(i + 1, ap + [ln[i]], bp, cp),
            dfs(i + 1, ap, bp + [ln[i]], cp),
            dfs(i + 1, ap, bp, cp + [ln[i]]),
            dfs(i + 1, ap, bp, cp)
        ]) dfs pattern = [ap, bp, cp] pattern [ap, bp, cp] ap bp cp if i >= n and [] not in pattern:
        mp = 0
        for p in pattern:
            mp += max([0, len(p) - 1]) * 10
        mp += abs(a - sum(pattern[0]))
        mp += abs(b - sum(pattern[1]))
        mp += abs(c - sum(pattern[2]))
        return mp
    elif i >= n:
        return float('inf')
    else:
        return min([
            dfs(i + 1, ap + [ln[i]], bp, cp),
            dfs(i + 1, ap, bp + [ln[i]], cp),
            dfs(i + 1, ap, bp, cp + [ln[i]]),
            dfs(i + 1, ap, bp, cp)
        ]) i >= n and [] not in pattern i >= n i n [] not in pattern [] pattern mp = 0 mp 0 for p in pattern:
            mp += max([0, len(p) - 1]) * 10
         p pattern mp += max([0, len(p) - 1]) * 10 mp max([0, len(p) - 1]) * 10 max([0, len(p) - 1]) max [0, len(p) - 1] 0 len(p) - 1 len(p) len p 1 10 mp += abs(a - sum(pattern[0])) mp abs(a - sum(pattern[0])) abs a - sum(pattern[0]) a sum(pattern[0]) sum pattern[0] pattern 0 mp += abs(b - sum(pattern[1])) mp abs(b - sum(pattern[1])) abs b - sum(pattern[1]) b sum(pattern[1]) sum pattern[1] pattern 1 mp += abs(c - sum(pattern[2])) mp abs(c - sum(pattern[2])) abs c - sum(pattern[2]) c sum(pattern[2]) sum pattern[2] pattern 2 return mp mp elif i >= n:
        return float('inf')
     i >= n i n return float('inf') float('inf') float 'inf' return min([
            dfs(i + 1, ap + [ln[i]], bp, cp),
            dfs(i + 1, ap, bp + [ln[i]], cp),
            dfs(i + 1, ap, bp, cp + [ln[i]]),
            dfs(i + 1, ap, bp, cp)
        ]) min([
            dfs(i + 1, ap + [ln[i]], bp, cp),
            dfs(i + 1, ap, bp + [ln[i]], cp),
            dfs(i + 1, ap, bp, cp + [ln[i]]),
            dfs(i + 1, ap, bp, cp)
        ]) min [
            dfs(i + 1, ap + [ln[i]], bp, cp),
            dfs(i + 1, ap, bp + [ln[i]], cp),
            dfs(i + 1, ap, bp, cp + [ln[i]]),
            dfs(i + 1, ap, bp, cp)
        ] dfs(i + 1, ap + [ln[i]], bp, cp) dfs i + 1 i 1 ap + [ln[i]] ap [ln[i]] ln[i] ln i bp cp dfs(i + 1, ap, bp + [ln[i]], cp) dfs i + 1 i 1 ap bp + [ln[i]] bp [ln[i]] ln[i] ln i cp dfs(i + 1, ap, bp, cp + [ln[i]]) dfs i + 1 i 1 ap bp cp + [ln[i]] cp [ln[i]] ln[i] ln i dfs(i + 1, ap, bp, cp) dfs i + 1 i 1 ap bp cp i i ap ap bp bp cp cp result = dfs(0, [], [], []) result dfs(0, [], [], []) dfs 0 [] [] [] print(result) print result def dfs(i, ap, bp, cp):
    pattern = [ap, bp, cp]
    if i >= n and [] not in pattern:
        mp = 0
        for p in pattern:
            mp += max([0, len(p) - 1]) * 10
        mp += abs(a - sum(pattern[0]))
        mp += abs(b - sum(pattern[1]))
        mp += abs(c - sum(pattern[2]))
        return mp
    elif i >= n:
        return float('inf')
    else:
        return min([
            dfs(i + 1, ap + [ln[i]], bp, cp),
            dfs(i + 1, ap, bp + [ln[i]], cp),
            dfs(i + 1, ap, bp, cp + [ln[i]]),
            dfs(i + 1, ap, bp, cp)
        ]) def dfs(i, ap, bp, cp):
    pattern = [ap, bp, cp]
    if i >= n and [] not in pattern:
        mp = 0
        for p in pattern:
            mp += max([0, len(p) - 1]) * 10
        mp += abs(a - sum(pattern[0]))
        mp += abs(b - sum(pattern[1]))
        mp += abs(c - sum(pattern[2]))
        return mp
    elif i >= n:
        return float('inf')
    else:
        return min([
            dfs(i + 1, ap + [ln[i]], bp, cp),
            dfs(i + 1, ap, bp + [ln[i]], cp),
            dfs(i + 1, ap, bp, cp + [ln[i]]),
            dfs(i + 1, ap, bp, cp)
        ]) dfs b, c = list(map(int, input().split(' '))) list(map(int, input().split(' '))) b n, a, b, c = list(map(int, input().split(' '))) list(map(int, input().split(' '))) n c = list(map(int, input().split(' '))) list(map(int, input().split(' '))) c result = dfs(0, [], [], []) dfs(0, [], [], []) result a, b, c = list(map(int, input().split(' '))) list(map(int, input().split(' '))) a ln = [None] * n [None] * n ln
n, a, b, c = list(map(int, input().split(' ')))
ln = [None] * n
for i in range(n):
    ln[i] = (int(input()))


def dfs(i, ap, bp, cp):
    pattern = [ap, bp, cp]
    if i >= n and [] not in pattern:
        mp = 0
        for p in pattern:
            mp += max([0, len(p) - 1]) * 10
        mp += abs(a - sum(pattern[0]))
        mp += abs(b - sum(pattern[1]))
        mp += abs(c - sum(pattern[2]))
        return mp
    elif i >= n:
        return float('inf')
    else:
        return min([
            dfs(i + 1, ap + [ln[i]], bp, cp),
            dfs(i + 1, ap, bp + [ln[i]], cp),
            dfs(i + 1, ap, bp, cp + [ln[i]]),
            dfs(i + 1, ap, bp, cp)
        ])


result = dfs(0, [], [], [])
print(result)


