#119-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
from itertools import permutations
n,a,b,c=IL()
ll=[]
for i in range(n):
    l=I()
    ll.append(l)
ans=float("INF")
for k in range(3,n+1):
    perms=permutations(range(n),k)
    for perm in perms:
        tans=(k-1)*10-2*10
        for i in range(1,k-1):
            for j in range(i+1,k):
                l=perm[:i]
                m=perm[i:j]
                r=perm[j:]
                vl,ml,rl=0,0,0
                for o in l:
                    vl+=ll[o]
                for o in m:
                    ml+=ll[o]
                for o in r:
                    rl+=ll[o]
                vv=[vl,ml,rl]
                vv.sort()
                tans+=abs(c-vv[0])+abs(b-vv[1])+abs(a-vv[2])
                ans=min(ans,tans)
print(ans)