from itertools import product
p=4
n,a,b,c=map(int,input().split())
banboo=[0]*n
for i in range(n):
    banboo[i]=int(input())

Bit_4=list(product(range(p),repeat=n))
ans=10**6
for Bi in Bit_4:
    tmp=[0]*4
    magic=0
    if 1 in Bi and 2 in Bi and 3 in Bi:
        for i in range(n):
            tmp[Bi[i]]+=banboo[i]
            if tmp[Bi[i]]!=banboo[i] and Bi[i]!=0:
                magic+=10
        magic+=abs(tmp[1]-a)
        magic+=abs(tmp[2]-b)
        magic+=abs(tmp[3]-c)
        ans=min(magic,ans)
print(ans) from itertools import product p=4 p 4 n,a,b,c=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split a b c banboo=[0]*n banboo [0]*n [0] 0 n for i in range(n):
    banboo[i]=int(input()) i range(n) range n banboo[i]=int(input()) banboo[i] banboo i int(input()) int input() input Bit_4=list(product(range(p),repeat=n)) Bit_4 list(product(range(p),repeat=n)) list product(range(p),repeat=n) product range(p) range p repeat=n repeat n ans=10**6 ans 10**6 10 6 for Bi in Bit_4:
    tmp=[0]*4
    magic=0
    if 1 in Bi and 2 in Bi and 3 in Bi:
        for i in range(n):
            tmp[Bi[i]]+=banboo[i]
            if tmp[Bi[i]]!=banboo[i] and Bi[i]!=0:
                magic+=10
        magic+=abs(tmp[1]-a)
        magic+=abs(tmp[2]-b)
        magic+=abs(tmp[3]-c)
        ans=min(magic,ans) Bi Bit_4 tmp=[0]*4 tmp [0]*4 [0] 0 4 magic=0 magic 0 if 1 in Bi and 2 in Bi and 3 in Bi:
        for i in range(n):
            tmp[Bi[i]]+=banboo[i]
            if tmp[Bi[i]]!=banboo[i] and Bi[i]!=0:
                magic+=10
        magic+=abs(tmp[1]-a)
        magic+=abs(tmp[2]-b)
        magic+=abs(tmp[3]-c)
        ans=min(magic,ans) 1 in Bi and 2 in Bi and 3 in Bi 1 in Bi and 2 in Bi 1 in Bi 1 Bi 2 in Bi 2 Bi 3 in Bi 3 Bi for i in range(n):
            tmp[Bi[i]]+=banboo[i]
            if tmp[Bi[i]]!=banboo[i] and Bi[i]!=0:
                magic+=10
         i range(n) range n tmp[Bi[i]]+=banboo[i] tmp[Bi[i]] tmp Bi[i] Bi i banboo[i] banboo i if tmp[Bi[i]]!=banboo[i] and Bi[i]!=0:
                magic+=10
         tmp[Bi[i]]!=banboo[i] and Bi[i]!=0 tmp[Bi[i]]!=banboo[i] tmp[Bi[i]] tmp Bi[i] Bi i banboo[i] banboo i Bi[i]!=0 Bi[i] Bi i 0 magic+=10 magic 10 magic+=abs(tmp[1]-a) magic abs(tmp[1]-a) abs tmp[1]-a tmp[1] tmp 1 a magic+=abs(tmp[2]-b) magic abs(tmp[2]-b) abs tmp[2]-b tmp[2] tmp 2 b magic+=abs(tmp[3]-c) magic abs(tmp[3]-c) abs tmp[3]-c tmp[3] tmp 3 c ans=min(magic,ans) ans min(magic,ans) min magic ans print(ans) print ans magic+=abs(tmp[1]-a) abs(tmp[1]-a) magic b,c=map(int,input().split()) map(int,input().split()) b p=4 4 p magic+=abs(tmp[2]-b) abs(tmp[2]-b) magic ans=min(magic,ans) min(magic,ans) ans ans=10**6 10**6 ans magic=0 0 magic Bit_4=list(product(range(p),repeat=n)) list(product(range(p),repeat=n)) Bit_4 c=map(int,input().split()) map(int,input().split()) c magic+=abs(tmp[3]-c) abs(tmp[3]-c) magic tmp=[0]*4 [0]*4 tmp 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 banboo=[0]*n [0]*n banboo magic+=10 10 magic
from itertools import product
p=4
n,a,b,c=map(int,input().split())
banboo=[0]*n
for i in range(n):
    banboo[i]=int(input())

Bit_4=list(product(range(p),repeat=n))
ans=10**6
for Bi in Bit_4:
    tmp=[0]*4
    magic=0
    if 1 in Bi and 2 in Bi and 3 in Bi:
        for i in range(n):
            tmp[Bi[i]]+=banboo[i]
            if tmp[Bi[i]]!=banboo[i] and Bi[i]!=0:
                magic+=10
        magic+=abs(tmp[1]-a)
        magic+=abs(tmp[2]-b)
        magic+=abs(tmp[3]-c)
        ans=min(magic,ans)
print(ans)