# coding: utf-8
import sys
sys.setrecursionlimit(10**9)
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 = []
for i in range(N):
    L.append(int(input()))
# L.sort()
def dfs(cnt, a, b, c):
    if cnt == N:
        return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a,b,c) > 0 else 10**9
    r0 = dfs(cnt+1, a, b, c)
    r1 = dfs(cnt+1, a+L[cnt], b, c) + 10
    r2 = dfs(cnt+1, a, b+L[cnt], c) + 10
    r3 = dfs(cnt+1, a, b, c+L[cnt]) + 10
    return min(r0, r1, r2, r3)
    
print(dfs(0,0,0,0)) import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 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 L = [] L [] for i in range(N):
    L.append(int(input()))
# L.sort() i range(N) range N L.append(int(input())) L.append L append int(input()) int input() input def dfs(cnt, a, b, c):
    if cnt == N:
        return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a,b,c) > 0 else 10**9
    r0 = dfs(cnt+1, a, b, c)
    r1 = dfs(cnt+1, a+L[cnt], b, c) + 10
    r2 = dfs(cnt+1, a, b+L[cnt], c) + 10
    r3 = dfs(cnt+1, a, b, c+L[cnt]) + 10
    return min(r0, r1, r2, r3)
     dfs if cnt == N:
        return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a,b,c) > 0 else 10**9
     cnt == N cnt N return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a,b,c) > 0 else 10**9 abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a,b,c) > 0 else 10**9 min(a,b,c) > 0 min(a,b,c) min a b c 0 abs(A - a) + abs(B - b) + abs(C - c) - 30 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 30 10**9 10 9 r0 = dfs(cnt+1, a, b, c) r0 dfs(cnt+1, a, b, c) dfs cnt+1 cnt 1 a b c r1 = dfs(cnt+1, a+L[cnt], b, c) + 10 r1 dfs(cnt+1, a+L[cnt], b, c) + 10 dfs(cnt+1, a+L[cnt], b, c) dfs cnt+1 cnt 1 a+L[cnt] a L[cnt] L cnt b c 10 r2 = dfs(cnt+1, a, b+L[cnt], c) + 10 r2 dfs(cnt+1, a, b+L[cnt], c) + 10 dfs(cnt+1, a, b+L[cnt], c) dfs cnt+1 cnt 1 a b+L[cnt] b L[cnt] L cnt c 10 r3 = dfs(cnt+1, a, b, c+L[cnt]) + 10 r3 dfs(cnt+1, a, b, c+L[cnt]) + 10 dfs(cnt+1, a, b, c+L[cnt]) dfs cnt+1 cnt 1 a b c+L[cnt] c L[cnt] L cnt 10 return min(r0, r1, r2, r3) min(r0, r1, r2, r3) min r0 r1 r2 r3 cnt cnt a a b b c c print(dfs(0,0,0,0)) print dfs(0,0,0,0) dfs 0 0 0 0 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 N, A, B, C = map(int, input().split()) map(int, input().split()) N L = [] [] L def dfs(cnt, a, b, c):
    if cnt == N:
        return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a,b,c) > 0 else 10**9
    r0 = dfs(cnt+1, a, b, c)
    r1 = dfs(cnt+1, a+L[cnt], b, c) + 10
    r2 = dfs(cnt+1, a, b+L[cnt], c) + 10
    r3 = dfs(cnt+1, a, b, c+L[cnt]) + 10
    return min(r0, r1, r2, r3)
     def dfs(cnt, a, b, c):
    if cnt == N:
        return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a,b,c) > 0 else 10**9
    r0 = dfs(cnt+1, a, b, c)
    r1 = dfs(cnt+1, a+L[cnt], b, c) + 10
    r2 = dfs(cnt+1, a, b+L[cnt], c) + 10
    r3 = dfs(cnt+1, a, b, c+L[cnt]) + 10
    return min(r0, r1, r2, r3)
     dfs C = map(int, input().split()) map(int, input().split()) C A, B, C = map(int, input().split()) map(int, input().split()) A B, C = map(int, input().split()) map(int, input().split()) B
# coding: utf-8
import sys
sys.setrecursionlimit(10**9)
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 = []
for i in range(N):
    L.append(int(input()))
# L.sort()
def dfs(cnt, a, b, c):
    if cnt == N:
        return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a,b,c) > 0 else 10**9
    r0 = dfs(cnt+1, a, b, c)
    r1 = dfs(cnt+1, a+L[cnt], b, c) + 10
    r2 = dfs(cnt+1, a, b+L[cnt], c) + 10
    r3 = dfs(cnt+1, a, b, c+L[cnt]) + 10
    return min(r0, r1, r2, r3)
    
print(dfs(0,0,0,0))