from itertools import product

n, a, b, c = map(int, input().split())
kumiawase = list(product(range(4), repeat=n))
L = []
for _ in range(n):
    L.append(int(input()))


ans = 10 ** 20

for kumi in kumiawase:
    temp = 0
    L0 = []
    L1 = []
    L2 = []
    for j in range(n):
        if kumi[j] == 0:
            L0.append(L[j])
        if kumi[j] == 1:
            L1.append(L[j])
        if kumi[j] == 2:
            L2.append(L[j])
    n0 = len(L0)
    n1 = len(L1)
    n2 = len(L2)
    if n0 == 0 or n1 == 0 or n2 == 0:
        continue
    l0 = sum(L0)
    l1 = sum(L1)
    l2 = sum(L2)
    temp = 10 * (n0 - 1 + n1 - 1 + n2 - 1) + abs(l0 - a) + abs(l1 - b) + abs(l2 - c)
    ans = min(temp, ans)
print(ans) from itertools import product n, a, b, c = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split a b c kumiawase = list(product(range(4), repeat=n)) kumiawase list(product(range(4), repeat=n)) list product(range(4), repeat=n) product range(4) range 4 repeat=n repeat n L = [] L [] for _ in range(n):
    L.append(int(input())) _ range(n) range n L.append(int(input())) L.append L append int(input()) int input() input ans = 10 ** 20 ans 10 ** 20 10 20 for kumi in kumiawase:
    temp = 0
    L0 = []
    L1 = []
    L2 = []
    for j in range(n):
        if kumi[j] == 0:
            L0.append(L[j])
        if kumi[j] == 1:
            L1.append(L[j])
        if kumi[j] == 2:
            L2.append(L[j])
    n0 = len(L0)
    n1 = len(L1)
    n2 = len(L2)
    if n0 == 0 or n1 == 0 or n2 == 0:
        continue
    l0 = sum(L0)
    l1 = sum(L1)
    l2 = sum(L2)
    temp = 10 * (n0 - 1 + n1 - 1 + n2 - 1) + abs(l0 - a) + abs(l1 - b) + abs(l2 - c)
    ans = min(temp, ans) kumi kumiawase temp = 0 temp 0 L0 = [] L0 [] L1 = [] L1 [] L2 = [] L2 [] for j in range(n):
        if kumi[j] == 0:
            L0.append(L[j])
        if kumi[j] == 1:
            L1.append(L[j])
        if kumi[j] == 2:
            L2.append(L[j])
     j range(n) range n if kumi[j] == 0:
            L0.append(L[j])
         kumi[j] == 0 kumi[j] kumi j 0 L0.append(L[j]) L0.append L0 append L[j] L j if kumi[j] == 1:
            L1.append(L[j])
         kumi[j] == 1 kumi[j] kumi j 1 L1.append(L[j]) L1.append L1 append L[j] L j if kumi[j] == 2:
            L2.append(L[j])
     kumi[j] == 2 kumi[j] kumi j 2 L2.append(L[j]) L2.append L2 append L[j] L j n0 = len(L0) n0 len(L0) len L0 n1 = len(L1) n1 len(L1) len L1 n2 = len(L2) n2 len(L2) len L2 if n0 == 0 or n1 == 0 or n2 == 0:
        continue
     n0 == 0 or n1 == 0 or n2 == 0 n0 == 0 or n1 == 0 n0 == 0 n0 0 n1 == 0 n1 0 n2 == 0 n2 0 continue l0 = sum(L0) l0 sum(L0) sum L0 l1 = sum(L1) l1 sum(L1) sum L1 l2 = sum(L2) l2 sum(L2) sum L2 temp = 10 * (n0 - 1 + n1 - 1 + n2 - 1) + abs(l0 - a) + abs(l1 - b) + abs(l2 - c) temp 10 * (n0 - 1 + n1 - 1 + n2 - 1) + abs(l0 - a) + abs(l1 - b) + abs(l2 - c) 10 * (n0 - 1 + n1 - 1 + n2 - 1) + abs(l0 - a) + abs(l1 - b) 10 * (n0 - 1 + n1 - 1 + n2 - 1) + abs(l0 - a) 10 * (n0 - 1 + n1 - 1 + n2 - 1) 10 n0 - 1 + n1 - 1 + n2 - 1 n0 - 1 + n1 - 1 + n2 n0 - 1 + n1 - 1 n0 - 1 + n1 n0 - 1 n0 1 n1 1 n2 1 abs(l0 - a) abs l0 - a l0 a abs(l1 - b) abs l1 - b l1 b abs(l2 - c) abs l2 - c l2 c ans = min(temp, ans) ans min(temp, ans) min temp ans print(ans) print ans ans = 10 ** 20 10 ** 20 ans ans = min(temp, ans) min(temp, ans) ans n2 = len(L2) len(L2) n2 kumiawase = list(product(range(4), repeat=n)) list(product(range(4), repeat=n)) kumiawase l2 = sum(L2) sum(L2) l2 a, b, c = map(int, input().split()) map(int, input().split()) a n1 = len(L1) len(L1) n1 n0 = len(L0) len(L0) n0 n, a, b, c = map(int, input().split()) map(int, input().split()) n L0 = [] [] L0 L1 = [] [] L1 b, c = map(int, input().split()) map(int, input().split()) b l0 = sum(L0) sum(L0) l0 L2 = [] [] L2 L = [] [] L l1 = sum(L1) sum(L1) l1 temp = 0 0 temp temp = 10 * (n0 - 1 + n1 - 1 + n2 - 1) + abs(l0 - a) + abs(l1 - b) + abs(l2 - c) 10 * (n0 - 1 + n1 - 1 + n2 - 1) + abs(l0 - a) + abs(l1 - b) + abs(l2 - c) temp c = map(int, input().split()) map(int, input().split()) c
from itertools import product

n, a, b, c = map(int, input().split())
kumiawase = list(product(range(4), repeat=n))
L = []
for _ in range(n):
    L.append(int(input()))


ans = 10 ** 20

for kumi in kumiawase:
    temp = 0
    L0 = []
    L1 = []
    L2 = []
    for j in range(n):
        if kumi[j] == 0:
            L0.append(L[j])
        if kumi[j] == 1:
            L1.append(L[j])
        if kumi[j] == 2:
            L2.append(L[j])
    n0 = len(L0)
    n1 = len(L1)
    n2 = len(L2)
    if n0 == 0 or n1 == 0 or n2 == 0:
        continue
    l0 = sum(L0)
    l1 = sum(L1)
    l2 = sum(L2)
    temp = 10 * (n0 - 1 + n1 - 1 + n2 - 1) + abs(l0 - a) + abs(l1 - b) + abs(l2 - c)
    ans = min(temp, ans)
print(ans)
