# coding: utf-8
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
    
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]
ans = float("inf")
for i in range(4**N):
    bits = Base_10_to_n(i, 4).zfill(N)
    a, b, c = 0, 0, 0
    cost = 0
    for j in range(len(bits)):
        if bits[j] == "0":
            pass
        elif bits[j] == "1":
            a += L[j]
            cost += 10
        elif bits[j] == "2":
            b += L[j]
            cost += 10
        else:
            c += L[j]
            cost += 10
    if min(a, b, c) > 0:
        ans = min(ans, cost + abs(a-A)+abs(b-B)+abs(c-C) - 10*3)
print(ans) def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
     Base_10_to_n X_dumy = X X_dumy X out = '' out '' while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
     X_dumy>0 X_dumy 0 out = str(X_dumy%n)+out out str(X_dumy%n)+out str(X_dumy%n) str X_dumy%n X_dumy n out X_dumy = int(X_dumy/n) X_dumy int(X_dumy/n) int X_dumy/n X_dumy n return out out X X n n 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 = float("inf") ans float("inf") float "inf" for i in range(4**N):
    bits = Base_10_to_n(i, 4).zfill(N)
    a, b, c = 0, 0, 0
    cost = 0
    for j in range(len(bits)):
        if bits[j] == "0":
            pass
        elif bits[j] == "1":
            a += L[j]
            cost += 10
        elif bits[j] == "2":
            b += L[j]
            cost += 10
        else:
            c += L[j]
            cost += 10
    if min(a, b, c) > 0:
        ans = min(ans, cost + abs(a-A)+abs(b-B)+abs(c-C) - 10*3) i range(4**N) range 4**N 4 N bits = Base_10_to_n(i, 4).zfill(N) bits Base_10_to_n(i, 4).zfill(N) (i, 4).zfill (i, 4) Base_10_to_n i 4 zfill N a, b, c = 0, 0, 0 a 0 b 0 c 0 cost = 0 cost 0 for j in range(len(bits)):
        if bits[j] == "0":
            pass
        elif bits[j] == "1":
            a += L[j]
            cost += 10
        elif bits[j] == "2":
            b += L[j]
            cost += 10
        else:
            c += L[j]
            cost += 10
     j range(len(bits)) range len(bits) len bits if bits[j] == "0":
            pass
        elif bits[j] == "1":
            a += L[j]
            cost += 10
        elif bits[j] == "2":
            b += L[j]
            cost += 10
        else:
            c += L[j]
            cost += 10
     bits[j] == "0" bits[j] bits j "0" elif bits[j] == "1":
            a += L[j]
            cost += 10
         bits[j] == "1" bits[j] bits j "1" a += L[j] a L[j] L j cost += 10 cost 10 elif bits[j] == "2":
            b += L[j]
            cost += 10
         bits[j] == "2" bits[j] bits j "2" b += L[j] b L[j] L j cost += 10 cost 10 c += L[j] c L[j] L j cost += 10 cost 10 if min(a, b, c) > 0:
        ans = min(ans, cost + abs(a-A)+abs(b-B)+abs(c-C) - 10*3) min(a, b, c) > 0 min(a, b, c) min a b c 0 ans = min(ans, cost + abs(a-A)+abs(b-B)+abs(c-C) - 10*3) ans min(ans, cost + abs(a-A)+abs(b-B)+abs(c-C) - 10*3) min ans cost + abs(a-A)+abs(b-B)+abs(c-C) - 10*3 cost + abs(a-A)+abs(b-B)+abs(c-C) cost + abs(a-A)+abs(b-B) cost + abs(a-A) cost abs(a-A) abs a-A a A abs(b-B) abs b-B b B abs(c-C) abs c-C c C 10*3 10 3 print(ans) print ans b += L[j] L[j] b def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
     def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
     Base_10_to_n B, C = map(int, input().split()) map(int, input().split()) B b, c = 0, 0, 0 0 b cost = 0 0 cost L = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] L ans = float("inf") float("inf") ans a, b, c = 0, 0, 0 0 a a += L[j] L[j] a c += L[j] L[j] c C = map(int, input().split()) map(int, input().split()) C cost += 10 10 cost bits = Base_10_to_n(i, 4).zfill(N) Base_10_to_n(i, 4).zfill(N) bits ans = min(ans, cost + abs(a-A)+abs(b-B)+abs(c-C) - 10*3) min(ans, cost + abs(a-A)+abs(b-B)+abs(c-C) - 10*3) ans A, B, C = map(int, input().split()) map(int, input().split()) A cost += 10 10 cost cost += 10 10 cost N, A, B, C = map(int, input().split()) map(int, input().split()) N c = 0, 0, 0 0 c
# coding: utf-8
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
    
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]
ans = float("inf")
for i in range(4**N):
    bits = Base_10_to_n(i, 4).zfill(N)
    a, b, c = 0, 0, 0
    cost = 0
    for j in range(len(bits)):
        if bits[j] == "0":
            pass
        elif bits[j] == "1":
            a += L[j]
            cost += 10
        elif bits[j] == "2":
            b += L[j]
            cost += 10
        else:
            c += L[j]
            cost += 10
    if min(a, b, c) > 0:
        ans = min(ans, cost + abs(a-A)+abs(b-B)+abs(c-C) - 10*3)
print(ans)