from itertools import product
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**16
    n,*abc=MI()
    ll=[II() for _ in range(n)]

    ans=inf
    for pp in product(range(4),repeat=n):
        ss=[0]*3
        cnt=[0]*3
        for l,p in zip(ll,pp):
            if p==3:continue
            ss[p]+=l
            cnt[p]+=1
        cur=0
        for i in range(3):
            if cnt[i]==0:
                cur=inf
                break
            cur+=(cnt[i]-1)*10+abs(abc[i]-ss[i])
        #print(pp,cur)
        ans=min(ans,cur)

    print(ans)

main() from itertools import product import sys sys sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 int1 = lambda x: int(x) - 1 int1 lambda x: int(x) - 1 int(x) - 1 int(x) int x 1 x p2D = lambda x: print(*x, sep="\n") p2D lambda x: print(*x, sep="\n") print(*x, sep="\n") print *x x sep="\n" sep "\n" x def II(): return int(sys.stdin.readline()) II def MI(): return map(int, sys.stdin.readline().split()) MI def LI(): return list(map(int, sys.stdin.readline().split())) LI LI() for _ in range(rows_number) for _ in range(rows_number) _ range(rows_number) range rows_number for _ in range(rows_number) LI() LI def LLI(rows_number): return [LI() for _ in range(rows_number)] LLI rows_number rows_number def SI(): return sys.stdin.readline()[:-1] SI def main():
    inf=10**16
    n,*abc=MI()
    ll=[II() for _ in range(n)]

    ans=inf
    for pp in product(range(4),repeat=n):
        ss=[0]*3
        cnt=[0]*3
        for l,p in zip(ll,pp):
            if p==3:continue
            ss[p]+=l
            cnt[p]+=1
        cur=0
        for i in range(3):
            if cnt[i]==0:
                cur=inf
                break
            cur+=(cnt[i]-1)*10+abs(abc[i]-ss[i])
        #print(pp,cur)
        ans=min(ans,cur)

    print(ans) main inf=10**16 inf 10**16 10 16 n,*abc=MI() n MI() MI *abc abc II() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) II() II ll=[II() for _ in range(n)] ll [II() for _ in range(n)] ans=inf ans inf for pp in product(range(4),repeat=n):
        ss=[0]*3
        cnt=[0]*3
        for l,p in zip(ll,pp):
            if p==3:continue
            ss[p]+=l
            cnt[p]+=1
        cur=0
        for i in range(3):
            if cnt[i]==0:
                cur=inf
                break
            cur+=(cnt[i]-1)*10+abs(abc[i]-ss[i])
        #print(pp,cur)
        ans=min(ans,cur)

     pp product(range(4),repeat=n) product range(4) range 4 repeat=n repeat n ss=[0]*3 ss [0]*3 [0] 0 3 cnt=[0]*3 cnt [0]*3 [0] 0 3 for l,p in zip(ll,pp):
            if p==3:continue
            ss[p]+=l
            cnt[p]+=1
         l p zip(ll,pp) zip ll pp if p==3:continue
             p==3 p 3 ss[p]+=l ss[p] ss p l cnt[p]+=1 cnt[p] cnt p 1 cur=0 cur 0 for i in range(3):
            if cnt[i]==0:
                cur=inf
                break
            cur+=(cnt[i]-1)*10+abs(abc[i]-ss[i])
        #print(pp,cur)
         i range(3) range 3 if cnt[i]==0:
                cur=inf
                break
             cnt[i]==0 cnt[i] cnt i 0 cur=inf cur inf break cur+=(cnt[i]-1)*10+abs(abc[i]-ss[i]) cur (cnt[i]-1)*10+abs(abc[i]-ss[i]) (cnt[i]-1)*10 cnt[i]-1 cnt[i] cnt i 1 10 abs(abc[i]-ss[i]) abs abc[i]-ss[i] abc[i] abc i ss[i] ss i ans=min(ans,cur) ans min(ans,cur) min ans cur print(ans) print ans main() main def LI(): return list(map(int, sys.stdin.readline().split())) def LI(): return list(map(int, sys.stdin.readline().split())) LI def II(): return int(sys.stdin.readline()) def II(): return int(sys.stdin.readline()) II def MI(): return map(int, sys.stdin.readline().split()) def MI(): return map(int, sys.stdin.readline().split()) MI p2D = lambda x: print(*x, sep="\n") lambda x: print(*x, sep="\n") p2D def SI(): return sys.stdin.readline()[:-1] def SI(): return sys.stdin.readline()[:-1] SI int1 = lambda x: int(x) - 1 lambda x: int(x) - 1 int1 def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI(rows_number): return [LI() for _ in range(rows_number)] LLI def main():
    inf=10**16
    n,*abc=MI()
    ll=[II() for _ in range(n)]

    ans=inf
    for pp in product(range(4),repeat=n):
        ss=[0]*3
        cnt=[0]*3
        for l,p in zip(ll,pp):
            if p==3:continue
            ss[p]+=l
            cnt[p]+=1
        cur=0
        for i in range(3):
            if cnt[i]==0:
                cur=inf
                break
            cur+=(cnt[i]-1)*10+abs(abc[i]-ss[i])
        #print(pp,cur)
        ans=min(ans,cur)

    print(ans) def main():
    inf=10**16
    n,*abc=MI()
    ll=[II() for _ in range(n)]

    ans=inf
    for pp in product(range(4),repeat=n):
        ss=[0]*3
        cnt=[0]*3
        for l,p in zip(ll,pp):
            if p==3:continue
            ss[p]+=l
            cnt[p]+=1
        cur=0
        for i in range(3):
            if cnt[i]==0:
                cur=inf
                break
            cur+=(cnt[i]-1)*10+abs(abc[i]-ss[i])
        #print(pp,cur)
        ans=min(ans,cur)

    print(ans) main
from itertools import product
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**16
    n,*abc=MI()
    ll=[II() for _ in range(n)]

    ans=inf
    for pp in product(range(4),repeat=n):
        ss=[0]*3
        cnt=[0]*3
        for l,p in zip(ll,pp):
            if p==3:continue
            ss[p]+=l
            cnt[p]+=1
        cur=0
        for i in range(3):
            if cnt[i]==0:
                cur=inf
                break
            cur+=(cnt[i]-1)*10+abs(abc[i]-ss[i])
        #print(pp,cur)
        ans=min(ans,cur)

    print(ans)

main()