from itertools import*
import numpy as np
n,a,b,c,*l=map(int,open(0).read().split())
d=np.array([a,b,c])
l=np.array(l)
ansl=[]
for s in product(range(4),repeat=n):
    if sum(i!=0for i in s)<3:
        continue
    else:
        ans=0
        s=np.array(s)
        x=s==1
        y=s==2
        z=s==3
        ans+=sum(abs(np.array([sum(l*x),sum(l*y),sum(l*z)])-d))+((sum(x)-1)+(sum(y)-1)+(sum(z)-1))*10
        ansl.append(ans)
print(min(ansl))