import itertools

n, a, b, c = map(int, input().split())
l = []
for i in range(n):
    l.append(int(input()))
mp = float("inf")
for i in itertools.product([0,1,2,3], repeat = n):
    if 0 not in i or 1 not in i or 2 not in i:
        continue
    la, lb, lc = 0, 0, 0
    temp = 0
    for j in range(3):
        temp += (i.count(j) - 1) * 10
    for j in range(n):
        if i[j] == 0:
            la += l[j]
        elif i[j] == 1:
            lb += l[j]
        elif i[j] == 2:
            lc += l[j]
    for j, k in [[la, a], [lb, b], [lc, c]]:
        temp += abs(j - k)
    mp = min(mp, temp)
print(mp) import itertools itertools 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 mp = float("inf") mp float("inf") float "inf" for i in itertools.product([0,1,2,3], repeat = n):
    if 0 not in i or 1 not in i or 2 not in i:
        continue
    la, lb, lc = 0, 0, 0
    temp = 0
    for j in range(3):
        temp += (i.count(j) - 1) * 10
    for j in range(n):
        if i[j] == 0:
            la += l[j]
        elif i[j] == 1:
            lb += l[j]
        elif i[j] == 2:
            lc += l[j]
    for j, k in [[la, a], [lb, b], [lc, c]]:
        temp += abs(j - k)
    mp = min(mp, temp) i itertools.product([0,1,2,3], repeat = n) itertools.product itertools product [0,1,2,3] 0 1 2 3 repeat = n repeat n if 0 not in i or 1 not in i or 2 not in i:
        continue
     0 not in i or 1 not in i or 2 not in i 0 not in i or 1 not in i 0 not in i 0 i 1 not in i 1 i 2 not in i 2 i continue la, lb, lc = 0, 0, 0 la 0 lb 0 lc 0 temp = 0 temp 0 for j in range(3):
        temp += (i.count(j) - 1) * 10
     j range(3) range 3 temp += (i.count(j) - 1) * 10 temp (i.count(j) - 1) * 10 i.count(j) - 1 i.count(j) i.count i count j 1 10 for j in range(n):
        if i[j] == 0:
            la += l[j]
        elif i[j] == 1:
            lb += l[j]
        elif i[j] == 2:
            lc += l[j]
     j range(n) range n if i[j] == 0:
            la += l[j]
        elif i[j] == 1:
            lb += l[j]
        elif i[j] == 2:
            lc += l[j]
     i[j] == 0 i[j] i j 0 la += l[j] la l[j] l j elif i[j] == 1:
            lb += l[j]
         i[j] == 1 i[j] i j 1 lb += l[j] lb l[j] l j elif i[j] == 2:
            lc += l[j]
     i[j] == 2 i[j] i j 2 lc += l[j] lc l[j] l j for j, k in [[la, a], [lb, b], [lc, c]]:
        temp += abs(j - k)
     j k [[la, a], [lb, b], [lc, c]] [la, a] la a [lb, b] lb b [lc, c] lc c temp += abs(j - k) temp abs(j - k) abs j - k j k mp = min(mp, temp) mp min(mp, temp) min mp temp print(mp) print mp 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 temp = 0 0 temp mp = min(mp, temp) min(mp, temp) mp l = [] [] l la, lb, lc = 0, 0, 0 0 la lc += l[j] l[j] lc la += l[j] l[j] la lb, lc = 0, 0, 0 0 lb lc = 0, 0, 0 0 lc temp += (i.count(j) - 1) * 10 (i.count(j) - 1) * 10 temp n, a, b, c = map(int, input().split()) map(int, input().split()) n temp += abs(j - k) abs(j - k) temp lb += l[j] l[j] lb mp = float("inf") float("inf") mp
import itertools

n, a, b, c = map(int, input().split())
l = []
for i in range(n):
    l.append(int(input()))
mp = float("inf")
for i in itertools.product([0,1,2,3], repeat = n):
    if 0 not in i or 1 not in i or 2 not in i:
        continue
    la, lb, lc = 0, 0, 0
    temp = 0
    for j in range(3):
        temp += (i.count(j) - 1) * 10
    for j in range(n):
        if i[j] == 0:
            la += l[j]
        elif i[j] == 1:
            lb += l[j]
        elif i[j] == 2:
            lc += l[j]
    for j, k in [[la, a], [lb, b], [lc, c]]:
        temp += abs(j - k)
    mp = min(mp, temp)
print(mp)