from itertools import product
N, A, B, C = map(int, input().split())
abc = [C, B, A]
lst = [int(input()) for _ in range(N)]

ans = []
for l in product([0, 1, 2, 3], repeat=N):
    cnt = [[], [], [], []]
    for i, ll in enumerate(l):
        cnt[ll].append(lst[i])
    mp = 0
    p = []
    for i in cnt[:3]:
        if len(i) != 0: mp += (len(i) - 1) * 10
        p.append(sum(i))
    p.sort()
    if p[0]!=0:
        for i in range(3):
            mp += abs(p[i] - abc[i])
        ans.append(mp)
print(min(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 abc = [C, B, A] abc [C, B, A] C B A int(input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input lst = [int(input()) for _ in range(N)] lst [int(input()) for _ in range(N)] ans = [] ans [] for l in product([0, 1, 2, 3], repeat=N):
    cnt = [[], [], [], []]
    for i, ll in enumerate(l):
        cnt[ll].append(lst[i])
    mp = 0
    p = []
    for i in cnt[:3]:
        if len(i) != 0: mp += (len(i) - 1) * 10
        p.append(sum(i))
    p.sort()
    if p[0]!=0:
        for i in range(3):
            mp += abs(p[i] - abc[i])
        ans.append(mp) l product([0, 1, 2, 3], repeat=N) product [0, 1, 2, 3] 0 1 2 3 repeat=N repeat N cnt = [[], [], [], []] cnt [[], [], [], []] [] [] [] [] for i, ll in enumerate(l):
        cnt[ll].append(lst[i])
     i ll enumerate(l) enumerate l cnt[ll].append(lst[i]) [ll].append [ll] cnt ll append lst[i] lst i mp = 0 mp 0 p = [] p [] for i in cnt[:3]:
        if len(i) != 0: mp += (len(i) - 1) * 10
        p.append(sum(i))
     i cnt[:3] cnt :3 3 if len(i) != 0: mp += (len(i) - 1) * 10
         len(i) != 0 len(i) len i 0 p.append(sum(i)) p.append p append sum(i) sum i p.sort() p.sort p sort if p[0]!=0:
        for i in range(3):
            mp += abs(p[i] - abc[i])
        ans.append(mp) p[0]!=0 p[0] p 0 0 for i in range(3):
            mp += abs(p[i] - abc[i])
         i range(3) range 3 mp += abs(p[i] - abc[i]) mp abs(p[i] - abc[i]) abs p[i] - abc[i] p[i] p i abc[i] abc i ans.append(mp) ans.append ans append mp print(min(ans)) print min(ans) min ans p = [] [] p cnt = [[], [], [], []] [[], [], [], []] cnt A, B, C = map(int, input().split()) map(int, input().split()) A C = map(int, input().split()) map(int, input().split()) C ans = [] [] ans N, A, B, C = map(int, input().split()) map(int, input().split()) N mp += abs(p[i] - abc[i]) abs(p[i] - abc[i]) mp abc = [C, B, A] [C, B, A] abc lst = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] lst B, C = map(int, input().split()) map(int, input().split()) B mp = 0 0 mp
from itertools import product
N, A, B, C = map(int, input().split())
abc = [C, B, A]
lst = [int(input()) for _ in range(N)]

ans = []
for l in product([0, 1, 2, 3], repeat=N):
    cnt = [[], [], [], []]
    for i, ll in enumerate(l):
        cnt[ll].append(lst[i])
    mp = 0
    p = []
    for i in cnt[:3]:
        if len(i) != 0: mp += (len(i) - 1) * 10
        p.append(sum(i))
    p.sort()
    if p[0]!=0:
        for i in range(3):
            mp += abs(p[i] - abc[i])
        ans.append(mp)
print(min(ans))