N, A, B, C = map(int, input().split())

l = []
for i in range(N):
    l.append(int(input()))

def dfs(i, a, b, c):
    if i == N:
        if min(a,b,c) == 0:
            return float("INF")
        else:
            return abs(a-A) + abs(b-B) + abs(c-C)
    else:
        ans0 = dfs(i+1, a, b, c) #棒iを使わないパターン
        ans1 = dfs(i+1, a+l[i], b, c) + (10 if a!=0 else 0)
        ans2 = dfs(i+1, a, b+l[i], c) + (10 if b!=0 else 0)
        ans3 = dfs(i+1, a, b, c+l[i]) + (10 if c!=0 else 0)
    return min(ans0, ans1, ans2, ans3)

print(dfs(0, 0, 0, 0)) 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())) i range(N) range N l.append(int(input())) l.append l append int(input()) int input() input def dfs(i, a, b, c):
    if i == N:
        if min(a,b,c) == 0:
            return float("INF")
        else:
            return abs(a-A) + abs(b-B) + abs(c-C)
    else:
        ans0 = dfs(i+1, a, b, c) #棒iを使わないパターン
        ans1 = dfs(i+1, a+l[i], b, c) + (10 if a!=0 else 0)
        ans2 = dfs(i+1, a, b+l[i], c) + (10 if b!=0 else 0)
        ans3 = dfs(i+1, a, b, c+l[i]) + (10 if c!=0 else 0)
    return min(ans0, ans1, ans2, ans3) dfs if i == N:
        if min(a,b,c) == 0:
            return float("INF")
        else:
            return abs(a-A) + abs(b-B) + abs(c-C)
    else:
        ans0 = dfs(i+1, a, b, c) #棒iを使わないパターン
        ans1 = dfs(i+1, a+l[i], b, c) + (10 if a!=0 else 0)
        ans2 = dfs(i+1, a, b+l[i], c) + (10 if b!=0 else 0)
        ans3 = dfs(i+1, a, b, c+l[i]) + (10 if c!=0 else 0)
     i == N i N if min(a,b,c) == 0:
            return float("INF")
        else:
            return abs(a-A) + abs(b-B) + abs(c-C)
     min(a,b,c) == 0 min(a,b,c) min a b c 0 return float("INF") float("INF") float "INF" return abs(a-A) + abs(b-B) + abs(c-C) 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 ans0 = dfs(i+1, a, b, c) ans0 dfs(i+1, a, b, c) dfs i+1 i 1 a b c ans1 = dfs(i+1, a+l[i], b, c) + (10 if a!=0 else 0) ans1 dfs(i+1, a+l[i], b, c) + (10 if a!=0 else 0) dfs(i+1, a+l[i], b, c) dfs i+1 i 1 a+l[i] a l[i] l i b c 10 if a!=0 else 0 a!=0 a 0 10 0 ans2 = dfs(i+1, a, b+l[i], c) + (10 if b!=0 else 0) ans2 dfs(i+1, a, b+l[i], c) + (10 if b!=0 else 0) dfs(i+1, a, b+l[i], c) dfs i+1 i 1 a b+l[i] b l[i] l i c 10 if b!=0 else 0 b!=0 b 0 10 0 ans3 = dfs(i+1, a, b, c+l[i]) + (10 if c!=0 else 0) ans3 dfs(i+1, a, b, c+l[i]) + (10 if c!=0 else 0) dfs(i+1, a, b, c+l[i]) dfs i+1 i 1 a b c+l[i] c l[i] l i 10 if c!=0 else 0 c!=0 c 0 10 0 return min(ans0, ans1, ans2, ans3) min(ans0, ans1, ans2, ans3) min ans0 ans1 ans2 ans3 i i a a b b c c print(dfs(0, 0, 0, 0)) print dfs(0, 0, 0, 0) dfs 0 0 0 0 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 l = [] [] l N, A, B, C = map(int, input().split()) map(int, input().split()) N def dfs(i, a, b, c):
    if i == N:
        if min(a,b,c) == 0:
            return float("INF")
        else:
            return abs(a-A) + abs(b-B) + abs(c-C)
    else:
        ans0 = dfs(i+1, a, b, c) #棒iを使わないパターン
        ans1 = dfs(i+1, a+l[i], b, c) + (10 if a!=0 else 0)
        ans2 = dfs(i+1, a, b+l[i], c) + (10 if b!=0 else 0)
        ans3 = dfs(i+1, a, b, c+l[i]) + (10 if c!=0 else 0)
    return min(ans0, ans1, ans2, ans3) def dfs(i, a, b, c):
    if i == N:
        if min(a,b,c) == 0:
            return float("INF")
        else:
            return abs(a-A) + abs(b-B) + abs(c-C)
    else:
        ans0 = dfs(i+1, a, b, c) #棒iを使わないパターン
        ans1 = dfs(i+1, a+l[i], b, c) + (10 if a!=0 else 0)
        ans2 = dfs(i+1, a, b+l[i], c) + (10 if b!=0 else 0)
        ans3 = dfs(i+1, a, b, c+l[i]) + (10 if c!=0 else 0)
    return min(ans0, ans1, ans2, ans3) dfs
N, A, B, C = map(int, input().split())

l = []
for i in range(N):
    l.append(int(input()))

def dfs(i, a, b, c):
    if i == N:
        if min(a,b,c) == 0:
            return float("INF")
        else:
            return abs(a-A) + abs(b-B) + abs(c-C)
    else:
        ans0 = dfs(i+1, a, b, c) #棒iを使わないパターン
        ans1 = dfs(i+1, a+l[i], b, c) + (10 if a!=0 else 0)
        ans2 = dfs(i+1, a, b+l[i], c) + (10 if b!=0 else 0)
        ans3 = dfs(i+1, a, b, c+l[i]) + (10 if c!=0 else 0)
    return min(ans0, ans1, ans2, ans3)

print(dfs(0, 0, 0, 0))
