#!/usr/bin/env python3


# import numpy as np

N, A, B, C = list(map(int, input().split()))
L = [int(input()) for _ in range(N)]


inf = 10**9


def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else inf

    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + L[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + L[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10

    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))
# ans = 1000
# for i in itertools.product([0, 1, 2, 3], repeat=n):

#     ans_tmp = 0
#     counter = collections.Counter(i)
#     print(counter)
#     if not((1 in counter) and (2 in counter) and (3 in counter)):
#         continue

#     length = [a, b, c]

#     for index, opt in enumerate(i):
#         if opt != 0:
#             length[opt-1] += L[index]

#     print(length)
#     ans_tmp += (counter[1]-1)*10
#     ans_tmp += (counter[2]-1)*10
#     ans_tmp += (counter[3]-1)*10

#     ans_tmp += abs(a - length[0])
#     ans_tmp += abs(b - length[1])
#     ans_tmp += abs(c - length[2])

#     ans = min(ans, ans_tmp)

# print(ans) 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 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)] inf = 10**9 inf 10**9 10 9 def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else inf

    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + L[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + L[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10

    return min(ret0, ret1, ret2, ret3) dfs if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else inf

     cur == N cur N return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else inf abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else inf 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 inf ret0 = dfs(cur + 1, a, b, c) ret0 dfs(cur + 1, a, b, c) dfs cur + 1 cur 1 a b c ret1 = dfs(cur + 1, a + L[cur], b, c) + 10 ret1 dfs(cur + 1, a + L[cur], b, c) + 10 dfs(cur + 1, a + L[cur], b, c) dfs cur + 1 cur 1 a + L[cur] a L[cur] L cur b c 10 ret2 = dfs(cur + 1, a, b + L[cur], c) + 10 ret2 dfs(cur + 1, a, b + L[cur], c) + 10 dfs(cur + 1, a, b + L[cur], c) dfs cur + 1 cur 1 a b + L[cur] b L[cur] L cur c 10 ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10 ret3 dfs(cur + 1, a, b, c + L[cur]) + 10 dfs(cur + 1, a, b, c + L[cur]) dfs cur + 1 cur 1 a b c + L[cur] c L[cur] L cur 10 return min(ret0, ret1, ret2, ret3) min(ret0, ret1, ret2, ret3) min ret0 ret1 ret2 ret3 cur cur a a b b c c print(dfs(0, 0, 0, 0)) print dfs(0, 0, 0, 0) dfs 0 0 0 0 L = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] L def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else inf

    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + L[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + L[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10

    return min(ret0, ret1, ret2, ret3) def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else inf

    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + L[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + L[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10

    return min(ret0, ret1, ret2, ret3) dfs inf = 10**9 10**9 inf B, C = list(map(int, input().split())) list(map(int, input().split())) B C = list(map(int, input().split())) list(map(int, input().split())) C N, A, B, C = list(map(int, input().split())) list(map(int, input().split())) N A, B, C = list(map(int, input().split())) list(map(int, input().split())) A
#!/usr/bin/env python3


# import numpy as np

N, A, B, C = list(map(int, input().split()))
L = [int(input()) for _ in range(N)]


inf = 10**9


def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else inf

    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + L[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + L[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10

    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))
# ans = 1000
# for i in itertools.product([0, 1, 2, 3], repeat=n):

#     ans_tmp = 0
#     counter = collections.Counter(i)
#     print(counter)
#     if not((1 in counter) and (2 in counter) and (3 in counter)):
#         continue

#     length = [a, b, c]

#     for index, opt in enumerate(i):
#         if opt != 0:
#             length[opt-1] += L[index]

#     print(length)
#     ans_tmp += (counter[1]-1)*10
#     ans_tmp += (counter[2]-1)*10
#     ans_tmp += (counter[3]-1)*10

#     ans_tmp += abs(a - length[0])
#     ans_tmp += abs(b - length[1])
#     ans_tmp += abs(c - length[2])

#     ans = min(ans, ans_tmp)

# print(ans)
