import itertools
from collections import Counter

n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]
le = [i for i in range(4)]

bb = list(itertools.product(le, repeat=n))
new = []
ans = 1145141919810

for ll in bb:
    aa = 0
    con = [0]*4
    amo = [0]*4
    for i in range(n):
        con[ll[i]] += l[i]
        amo[ll[i]] += 1
        
    if con[1] > 0 and con[2] > 0 and con[3] > 0:
        for j in range(1,4):
            aa += (amo[j] - 1) * 10
        aa += abs(con[1] - a)
        aa += abs(con[2] - b)
        aa += abs(con[3] - c)
        
        ans = min(ans,aa)
        
    else:
        continue
        
print(ans) import itertools itertools from collections import Counter n,a,b,c = map(int,input().split()) n 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)] i for i in range(4) for i in range(4) i range(4) range 4 for i in range(4) i le = [i for i in range(4)] le [i for i in range(4)] bb = list(itertools.product(le, repeat=n)) bb list(itertools.product(le, repeat=n)) list itertools.product(le, repeat=n) itertools.product itertools product le repeat=n repeat n new = [] new [] ans = 1145141919810 ans 1145141919810 for ll in bb:
    aa = 0
    con = [0]*4
    amo = [0]*4
    for i in range(n):
        con[ll[i]] += l[i]
        amo[ll[i]] += 1
        
    if con[1] > 0 and con[2] > 0 and con[3] > 0:
        for j in range(1,4):
            aa += (amo[j] - 1) * 10
        aa += abs(con[1] - a)
        aa += abs(con[2] - b)
        aa += abs(con[3] - c)
        
        ans = min(ans,aa)
        
    else:
        continue
         ll bb aa = 0 aa 0 con = [0]*4 con [0]*4 [0] 0 4 amo = [0]*4 amo [0]*4 [0] 0 4 for i in range(n):
        con[ll[i]] += l[i]
        amo[ll[i]] += 1
        
     i range(n) range n con[ll[i]] += l[i] con[ll[i]] con ll[i] ll i l[i] l i amo[ll[i]] += 1 amo[ll[i]] amo ll[i] ll i 1 if con[1] > 0 and con[2] > 0 and con[3] > 0:
        for j in range(1,4):
            aa += (amo[j] - 1) * 10
        aa += abs(con[1] - a)
        aa += abs(con[2] - b)
        aa += abs(con[3] - c)
        
        ans = min(ans,aa)
        
    else:
        continue
         con[1] > 0 and con[2] > 0 and con[3] > 0 con[1] > 0 and con[2] > 0 con[1] > 0 con[1] con 1 0 con[2] > 0 con[2] con 2 0 con[3] > 0 con[3] con 3 0 for j in range(1,4):
            aa += (amo[j] - 1) * 10
         j range(1,4) range 1 4 aa += (amo[j] - 1) * 10 aa (amo[j] - 1) * 10 amo[j] - 1 amo[j] amo j 1 10 aa += abs(con[1] - a) aa abs(con[1] - a) abs con[1] - a con[1] con 1 a aa += abs(con[2] - b) aa abs(con[2] - b) abs con[2] - b con[2] con 2 b aa += abs(con[3] - c) aa abs(con[3] - c) abs con[3] - c con[3] con 3 c ans = min(ans,aa) ans min(ans,aa) min ans aa continue print(ans) print ans aa += abs(con[2] - b) abs(con[2] - b) aa ans = 1145141919810 1145141919810 ans aa = 0 0 aa bb = list(itertools.product(le, repeat=n)) list(itertools.product(le, repeat=n)) bb c = map(int,input().split()) map(int,input().split()) c n,a,b,c = map(int,input().split()) map(int,input().split()) n aa += abs(con[3] - c) abs(con[3] - c) aa l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l le = [i for i in range(4)] [i for i in range(4)] le con = [0]*4 [0]*4 con amo = [0]*4 [0]*4 amo ans = min(ans,aa) min(ans,aa) ans aa += (amo[j] - 1) * 10 (amo[j] - 1) * 10 aa a,b,c = map(int,input().split()) map(int,input().split()) a new = [] [] new aa += abs(con[1] - a) abs(con[1] - a) aa b,c = map(int,input().split()) map(int,input().split()) b
import itertools
from collections import Counter

n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]
le = [i for i in range(4)]

bb = list(itertools.product(le, repeat=n))
new = []
ans = 1145141919810

for ll in bb:
    aa = 0
    con = [0]*4
    amo = [0]*4
    for i in range(n):
        con[ll[i]] += l[i]
        amo[ll[i]] += 1
        
    if con[1] > 0 and con[2] > 0 and con[3] > 0:
        for j in range(1,4):
            aa += (amo[j] - 1) * 10
        aa += abs(con[1] - a)
        aa += abs(con[2] - b)
        aa += abs(con[3] - c)
        
        ans = min(ans,aa)
        
    else:
        continue
        
print(ans)