n, a, b, c = map(int, input().split())

target = [a, b, c]
l = [int(input()) for _ in range(n)]

ans = 10**9

for i in range(1, 4 ** n):
    q = bin(i)[2:].zfill(n * 2)
    pattern = [q[2 * j:2 * j + 2] for j in range(n)]
    k = [[], [], []]
    for j in range(n):
        t = int(pattern[j], 2)
        if t == 0:
            continue
        k[t-1].append(l[j])
    if len(k[0]) * len(k[1]) * len(k[2]) == 0:
        continue
    cost = 0
    for j in range(3):
        cost += abs(sum(k[j]) - target[j]) + (len(k[j]) - 1) * 10
    ans = min(cost, ans)

print(ans) n, a, b, c = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split a b c target = [a, b, c] target [a, b, c] 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**9 ans 10**9 10 9 for i in range(1, 4 ** n):
    q = bin(i)[2:].zfill(n * 2)
    pattern = [q[2 * j:2 * j + 2] for j in range(n)]
    k = [[], [], []]
    for j in range(n):
        t = int(pattern[j], 2)
        if t == 0:
            continue
        k[t-1].append(l[j])
    if len(k[0]) * len(k[1]) * len(k[2]) == 0:
        continue
    cost = 0
    for j in range(3):
        cost += abs(sum(k[j]) - target[j]) + (len(k[j]) - 1) * 10
    ans = min(cost, ans) i range(1, 4 ** n) range 1 4 ** n 4 n q = bin(i)[2:].zfill(n * 2) q bin(i)[2:].zfill(n * 2) [2:].zfill [2:] (i) bin i 2: 2 zfill n * 2 n 2 q[2 * j:2 * j + 2] for j in range(n) for j in range(n) j range(n) range n for j in range(n) q[2 * j:2 * j + 2] q 2 * j:2 * j + 2 2 * j 2 j 2 * j + 2 2 * j 2 j 2 pattern = [q[2 * j:2 * j + 2] for j in range(n)] pattern [q[2 * j:2 * j + 2] for j in range(n)] k = [[], [], []] k [[], [], []] [] [] [] for j in range(n):
        t = int(pattern[j], 2)
        if t == 0:
            continue
        k[t-1].append(l[j])
     j range(n) range n t = int(pattern[j], 2) t int(pattern[j], 2) int pattern[j] pattern j 2 if t == 0:
            continue
         t == 0 t 0 continue k[t-1].append(l[j]) [t-1].append [t-1] k t-1 t 1 append l[j] l j if len(k[0]) * len(k[1]) * len(k[2]) == 0:
        continue
     len(k[0]) * len(k[1]) * len(k[2]) == 0 len(k[0]) * len(k[1]) * len(k[2]) len(k[0]) * len(k[1]) len(k[0]) len k[0] k 0 len(k[1]) len k[1] k 1 len(k[2]) len k[2] k 2 0 continue cost = 0 cost 0 for j in range(3):
        cost += abs(sum(k[j]) - target[j]) + (len(k[j]) - 1) * 10
     j range(3) range 3 cost += abs(sum(k[j]) - target[j]) + (len(k[j]) - 1) * 10 cost abs(sum(k[j]) - target[j]) + (len(k[j]) - 1) * 10 abs(sum(k[j]) - target[j]) abs sum(k[j]) - target[j] sum(k[j]) sum k[j] k j target[j] target j (len(k[j]) - 1) * 10 len(k[j]) - 1 len(k[j]) len k[j] k j 1 10 ans = min(cost, ans) ans min(cost, ans) min cost ans print(ans) print ans l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l cost = 0 0 cost ans = min(cost, ans) min(cost, ans) ans t = int(pattern[j], 2) int(pattern[j], 2) t c = map(int, input().split()) map(int, input().split()) c target = [a, b, c] [a, b, c] target a, b, c = map(int, input().split()) map(int, input().split()) a ans = 10**9 10**9 ans pattern = [q[2 * j:2 * j + 2] for j in range(n)] [q[2 * j:2 * j + 2] for j in range(n)] pattern q = bin(i)[2:].zfill(n * 2) bin(i)[2:].zfill(n * 2) q k = [[], [], []] [[], [], []] k cost += abs(sum(k[j]) - target[j]) + (len(k[j]) - 1) * 10 abs(sum(k[j]) - target[j]) + (len(k[j]) - 1) * 10 cost n, a, b, c = map(int, input().split()) map(int, input().split()) n b, c = map(int, input().split()) map(int, input().split()) b
n, a, b, c = map(int, input().split())

target = [a, b, c]
l = [int(input()) for _ in range(n)]

ans = 10**9

for i in range(1, 4 ** n):
    q = bin(i)[2:].zfill(n * 2)
    pattern = [q[2 * j:2 * j + 2] for j in range(n)]
    k = [[], [], []]
    for j in range(n):
        t = int(pattern[j], 2)
        if t == 0:
            continue
        k[t-1].append(l[j])
    if len(k[0]) * len(k[1]) * len(k[2]) == 0:
        continue
    cost = 0
    for j in range(3):
        cost += abs(sum(k[j]) - target[j]) + (len(k[j]) - 1) * 10
    ans = min(cost, ans)

print(ans)
