N,A,B,C=map(int,input().split())
l=[int(input()) for _ in range(N)]
dist=[A,B,C]
ans=float("inf")
for i in range(pow(4,N)):
    bit=[0]*N
    num=i
    x=[[],[],[]]
    cnt=0
    for j in range(N-1,-1,-1):
        bit[j]=num//pow(4,j)
        num=num%pow(4,j)
    #print(bit.count(1),bit.count(2),bit.count(3))
    if (bit.count(1)>0)and(bit.count(2)>0)and(bit.count(3)>0):
        #print(bit)
        for j in range(N):
            if bit[j]>0:
                x[bit[j]-1].append(l[j])
        for j in range(3):
            cnt=cnt+(len(x[j])-1)*10
            num=sum(x[j])
            cnt=cnt+abs(num-dist[j])
        ans=min(cnt,ans)
print(ans) 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)] dist=[A,B,C] dist [A,B,C] A B C ans=float("inf") ans float("inf") float "inf" for i in range(pow(4,N)):
    bit=[0]*N
    num=i
    x=[[],[],[]]
    cnt=0
    for j in range(N-1,-1,-1):
        bit[j]=num//pow(4,j)
        num=num%pow(4,j)
    #print(bit.count(1),bit.count(2),bit.count(3))
    if (bit.count(1)>0)and(bit.count(2)>0)and(bit.count(3)>0):
        #print(bit)
        for j in range(N):
            if bit[j]>0:
                x[bit[j]-1].append(l[j])
        for j in range(3):
            cnt=cnt+(len(x[j])-1)*10
            num=sum(x[j])
            cnt=cnt+abs(num-dist[j])
        ans=min(cnt,ans) i range(pow(4,N)) range pow(4,N) pow 4 N bit=[0]*N bit [0]*N [0] 0 N num=i num i x=[[],[],[]] x [[],[],[]] [] [] [] cnt=0 cnt 0 for j in range(N-1,-1,-1):
        bit[j]=num//pow(4,j)
        num=num%pow(4,j)
    #print(bit.count(1),bit.count(2),bit.count(3))
     j range(N-1,-1,-1) range N-1 N 1 -1 -1 bit[j]=num//pow(4,j) bit[j] bit j num//pow(4,j) num pow(4,j) pow 4 j num=num%pow(4,j) num num%pow(4,j) num pow(4,j) pow 4 j if (bit.count(1)>0)and(bit.count(2)>0)and(bit.count(3)>0):
        #print(bit)
        for j in range(N):
            if bit[j]>0:
                x[bit[j]-1].append(l[j])
        for j in range(3):
            cnt=cnt+(len(x[j])-1)*10
            num=sum(x[j])
            cnt=cnt+abs(num-dist[j])
        ans=min(cnt,ans) (bit.count(1)>0)and(bit.count(2)>0)and(bit.count(3)>0) (bit.count(1)>0)and(bit.count(2)>0) bit.count(1)>0 bit.count(1) bit.count bit count 1 0 bit.count(2)>0 bit.count(2) bit.count bit count 2 0 bit.count(3)>0 bit.count(3) bit.count bit count 3 0 for j in range(N):
            if bit[j]>0:
                x[bit[j]-1].append(l[j])
         j range(N) range N if bit[j]>0:
                x[bit[j]-1].append(l[j])
         bit[j]>0 bit[j] bit j 0 x[bit[j]-1].append(l[j]) [bit[j]-1].append [bit[j]-1] x bit[j]-1 bit[j] bit j 1 append l[j] l j for j in range(3):
            cnt=cnt+(len(x[j])-1)*10
            num=sum(x[j])
            cnt=cnt+abs(num-dist[j])
         j range(3) range 3 cnt=cnt+(len(x[j])-1)*10 cnt cnt+(len(x[j])-1)*10 cnt (len(x[j])-1)*10 len(x[j])-1 len(x[j]) len x[j] x j 1 10 num=sum(x[j]) num sum(x[j]) sum x[j] x j cnt=cnt+abs(num-dist[j]) cnt cnt+abs(num-dist[j]) cnt abs(num-dist[j]) abs num-dist[j] num dist[j] dist j ans=min(cnt,ans) ans min(cnt,ans) min cnt ans print(ans) print ans ans=float("inf") float("inf") ans x=[[],[],[]] [[],[],[]] x bit=[0]*N [0]*N bit l=[int(input()) for _ in range(N)] [int(input()) for _ in range(N)] l B,C=map(int,input().split()) map(int,input().split()) B ans=min(cnt,ans) min(cnt,ans) ans N,A,B,C=map(int,input().split()) map(int,input().split()) N A,B,C=map(int,input().split()) map(int,input().split()) A cnt=0 0 cnt dist=[A,B,C] [A,B,C] dist num=i i num cnt=cnt+abs(num-dist[j]) cnt+abs(num-dist[j]) cnt C=map(int,input().split()) map(int,input().split()) C num=num%pow(4,j) num%pow(4,j) num cnt=cnt+(len(x[j])-1)*10 cnt+(len(x[j])-1)*10 cnt num=sum(x[j]) sum(x[j]) num
N,A,B,C=map(int,input().split())
l=[int(input()) for _ in range(N)]
dist=[A,B,C]
ans=float("inf")
for i in range(pow(4,N)):
    bit=[0]*N
    num=i
    x=[[],[],[]]
    cnt=0
    for j in range(N-1,-1,-1):
        bit[j]=num//pow(4,j)
        num=num%pow(4,j)
    #print(bit.count(1),bit.count(2),bit.count(3))
    if (bit.count(1)>0)and(bit.count(2)>0)and(bit.count(3)>0):
        #print(bit)
        for j in range(N):
            if bit[j]>0:
                x[bit[j]-1].append(l[j])
        for j in range(3):
            cnt=cnt+(len(x[j])-1)*10
            num=sum(x[j])
            cnt=cnt+abs(num-dist[j])
        ans=min(cnt,ans)
print(ans)
