# dfs版
def dfs(d, A, B, C, f):
    global ans
    if d == n:
        if not 0 in [A, B, C]:
            ans = min(ans, abs(a - A) + abs(b - B) + abs(c - C) + f - 30)
        return
    dfs(d + 1, A, B, C, f)
    dfs(d + 1, A + l[d], B, C, f + 10)
    dfs(d + 1, A, B + l[d], C, f + 10)
    dfs(d + 1, A, B, C + l[d], f + 10)


n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
ans = 10 ** 10
dfs(0, 0, 0, 0, 0)
print(ans) def dfs(d, A, B, C, f):
    global ans
    if d == n:
        if not 0 in [A, B, C]:
            ans = min(ans, abs(a - A) + abs(b - B) + abs(c - C) + f - 30)
        return
    dfs(d + 1, A, B, C, f)
    dfs(d + 1, A + l[d], B, C, f + 10)
    dfs(d + 1, A, B + l[d], C, f + 10)
    dfs(d + 1, A, B, C + l[d], f + 10) dfs global ans if d == n:
        if not 0 in [A, B, C]:
            ans = min(ans, abs(a - A) + abs(b - B) + abs(c - C) + f - 30)
        return
     d == n d n if not 0 in [A, B, C]:
            ans = min(ans, abs(a - A) + abs(b - B) + abs(c - C) + f - 30)
         not 0 in [A, B, C] 0 in [A, B, C] 0 [A, B, C] A B C ans = min(ans, abs(a - A) + abs(b - B) + abs(c - C) + f - 30) ans min(ans, abs(a - A) + abs(b - B) + abs(c - C) + f - 30) min ans abs(a - A) + abs(b - B) + abs(c - C) + f - 30 abs(a - A) + abs(b - B) + abs(c - C) + f abs(a - A) + abs(b - B) + abs(c - C) abs(a - A) + abs(b - B) abs(a - A) abs a - A a A abs(b - B) abs b - B b B abs(c - C) abs c - C c C f 30 return dfs(d + 1, A, B, C, f) dfs d + 1 d 1 A B C f dfs(d + 1, A + l[d], B, C, f + 10) dfs d + 1 d 1 A + l[d] A l[d] l d B C f + 10 f 10 dfs(d + 1, A, B + l[d], C, f + 10) dfs d + 1 d 1 A B + l[d] B l[d] l d C f + 10 f 10 dfs(d + 1, A, B, C + l[d], f + 10) dfs d + 1 d 1 A B C + l[d] C l[d] l d f + 10 f 10 d d A A B B C C f f 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)] ans = 10 ** 10 ans 10 ** 10 10 10 dfs(0, 0, 0, 0, 0) dfs 0 0 0 0 0 print(ans) print ans n, a, b, c = map(int, input().split()) map(int, input().split()) n c = map(int, input().split()) map(int, input().split()) c l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l def dfs(d, A, B, C, f):
    global ans
    if d == n:
        if not 0 in [A, B, C]:
            ans = min(ans, abs(a - A) + abs(b - B) + abs(c - C) + f - 30)
        return
    dfs(d + 1, A, B, C, f)
    dfs(d + 1, A + l[d], B, C, f + 10)
    dfs(d + 1, A, B + l[d], C, f + 10)
    dfs(d + 1, A, B, C + l[d], f + 10) def dfs(d, A, B, C, f):
    global ans
    if d == n:
        if not 0 in [A, B, C]:
            ans = min(ans, abs(a - A) + abs(b - B) + abs(c - C) + f - 30)
        return
    dfs(d + 1, A, B, C, f)
    dfs(d + 1, A + l[d], B, C, f + 10)
    dfs(d + 1, A, B + l[d], C, f + 10)
    dfs(d + 1, A, B, C + l[d], f + 10) dfs b, c = map(int, input().split()) map(int, input().split()) b a, b, c = map(int, input().split()) map(int, input().split()) a ans = 10 ** 10 10 ** 10 ans
# dfs版
def dfs(d, A, B, C, f):
    global ans
    if d == n:
        if not 0 in [A, B, C]:
            ans = min(ans, abs(a - A) + abs(b - B) + abs(c - C) + f - 30)
        return
    dfs(d + 1, A, B, C, f)
    dfs(d + 1, A + l[d], B, C, f + 10)
    dfs(d + 1, A, B + l[d], C, f + 10)
    dfs(d + 1, A, B, C + l[d], f + 10)


n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
ans = 10 ** 10
dfs(0, 0, 0, 0, 0)
print(ans)
