# -*- coding: utf-8 -*-
n,a,b,c = list(map(int,input().split()))
l = [int(input()) for i in range(n)]

#a,b,cに使うベースの竹を選ぶ
from itertools import permutations,product
inf=float("inf")
min_mp = inf
for k in product(range(4),repeat=n):
    if 2 not in k or 1 not in k or 0 not in k:
        continue
    len_abc = [0,0,0]
    mp = - 30
    for i,v in enumerate(k):
        if v == 3:
            pass
        else:
            len_abc[v]+=l[i]
            mp += 10
    mp += (abs(a-len_abc[0])+abs(b-len_abc[1])+abs(c-len_abc[2]))
    min_mp = min(min_mp,mp)
print(min_mp) n,a,b,c = list(map(int,input().split())) n list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split a b c int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input l = [int(input()) for i in range(n)] l [int(input()) for i in range(n)] from itertools import permutations,product inf=float("inf") inf float("inf") float "inf" min_mp = inf min_mp inf for k in product(range(4),repeat=n):
    if 2 not in k or 1 not in k or 0 not in k:
        continue
    len_abc = [0,0,0]
    mp = - 30
    for i,v in enumerate(k):
        if v == 3:
            pass
        else:
            len_abc[v]+=l[i]
            mp += 10
    mp += (abs(a-len_abc[0])+abs(b-len_abc[1])+abs(c-len_abc[2]))
    min_mp = min(min_mp,mp) k product(range(4),repeat=n) product range(4) range 4 repeat=n repeat n if 2 not in k or 1 not in k or 0 not in k:
        continue
     2 not in k or 1 not in k or 0 not in k 2 not in k or 1 not in k 2 not in k 2 k 1 not in k 1 k 0 not in k 0 k continue len_abc = [0,0,0] len_abc [0,0,0] 0 0 0 mp = - 30 mp - 30 for i,v in enumerate(k):
        if v == 3:
            pass
        else:
            len_abc[v]+=l[i]
            mp += 10
     i v enumerate(k) enumerate k if v == 3:
            pass
        else:
            len_abc[v]+=l[i]
            mp += 10
     v == 3 v 3 len_abc[v]+=l[i] len_abc[v] len_abc v l[i] l i mp += 10 mp 10 mp += (abs(a-len_abc[0])+abs(b-len_abc[1])+abs(c-len_abc[2])) mp abs(a-len_abc[0])+abs(b-len_abc[1])+abs(c-len_abc[2]) abs(a-len_abc[0])+abs(b-len_abc[1]) abs(a-len_abc[0]) abs a-len_abc[0] a len_abc[0] len_abc 0 abs(b-len_abc[1]) abs b-len_abc[1] b len_abc[1] len_abc 1 abs(c-len_abc[2]) abs c-len_abc[2] c len_abc[2] len_abc 2 min_mp = min(min_mp,mp) min_mp min(min_mp,mp) min min_mp mp print(min_mp) print min_mp n,a,b,c = list(map(int,input().split())) list(map(int,input().split())) n a,b,c = list(map(int,input().split())) list(map(int,input().split())) a l = [int(input()) for i in range(n)] [int(input()) for i in range(n)] l len_abc = [0,0,0] [0,0,0] len_abc c = list(map(int,input().split())) list(map(int,input().split())) c mp += 10 10 mp inf=float("inf") float("inf") inf mp += (abs(a-len_abc[0])+abs(b-len_abc[1])+abs(c-len_abc[2])) abs(a-len_abc[0])+abs(b-len_abc[1])+abs(c-len_abc[2]) mp mp = - 30 - 30 mp min_mp = min(min_mp,mp) min(min_mp,mp) min_mp min_mp = inf inf min_mp b,c = list(map(int,input().split())) list(map(int,input().split())) b
# -*- coding: utf-8 -*-
n,a,b,c = list(map(int,input().split()))
l = [int(input()) for i in range(n)]

#a,b,cに使うベースの竹を選ぶ
from itertools import permutations,product
inf=float("inf")
min_mp = inf
for k in product(range(4),repeat=n):
    if 2 not in k or 1 not in k or 0 not in k:
        continue
    len_abc = [0,0,0]
    mp = - 30
    for i,v in enumerate(k):
        if v == 3:
            pass
        else:
            len_abc[v]+=l[i]
            mp += 10
    mp += (abs(a-len_abc[0])+abs(b-len_abc[1])+abs(c-len_abc[2]))
    min_mp = min(min_mp,mp)
print(min_mp)