n,a,b,c=map(int,input().split())
L=[int(input()) for _ in range(n)]

res2=1000000000

for i in range(2**n-1):
	for j in range(2**n-1):
		x=[]
		y=[]
		z=[]
		for k in range(n):
			
			if i>>k&1:
				if j>>k&1:
					x.append(L[k])
				else:
					y.append(L[k])
			else:
				if j>>k&1:
					z.append(L[k])
		res1=abs(sum(x)-a)+abs(sum(y)-b)+abs(sum(z)-c)
		
		if len(x)==0 or len(y)==0 or len(z)==0:
			continue
	
		if len(x)>1:
			res1+=10*(len(x)-1)
		if len(y)>1:
			res1+=10*(len(y)-1)
		if len(z)>1:
			res1+=10*(len(z)-1)				
		res2=min(res1,res2)

print(res2) 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)] res2=1000000000 res2 1000000000 for i in range(2**n-1):
	for j in range(2**n-1):
		x=[]
		y=[]
		z=[]
		for k in range(n):
			
			if i>>k&1:
				if j>>k&1:
					x.append(L[k])
				else:
					y.append(L[k])
			else:
				if j>>k&1:
					z.append(L[k])
		res1=abs(sum(x)-a)+abs(sum(y)-b)+abs(sum(z)-c)
		
		if len(x)==0 or len(y)==0 or len(z)==0:
			continue
	
		if len(x)>1:
			res1+=10*(len(x)-1)
		if len(y)>1:
			res1+=10*(len(y)-1)
		if len(z)>1:
			res1+=10*(len(z)-1)				
		res2=min(res1,res2) i range(2**n-1) range 2**n-1 2**n 2 n 1 for j in range(2**n-1):
		x=[]
		y=[]
		z=[]
		for k in range(n):
			
			if i>>k&1:
				if j>>k&1:
					x.append(L[k])
				else:
					y.append(L[k])
			else:
				if j>>k&1:
					z.append(L[k])
		res1=abs(sum(x)-a)+abs(sum(y)-b)+abs(sum(z)-c)
		
		if len(x)==0 or len(y)==0 or len(z)==0:
			continue
	
		if len(x)>1:
			res1+=10*(len(x)-1)
		if len(y)>1:
			res1+=10*(len(y)-1)
		if len(z)>1:
			res1+=10*(len(z)-1)				
		res2=min(res1,res2) j range(2**n-1) range 2**n-1 2**n 2 n 1 x=[] x [] y=[] y [] z=[] z [] for k in range(n):
			
			if i>>k&1:
				if j>>k&1:
					x.append(L[k])
				else:
					y.append(L[k])
			else:
				if j>>k&1:
					z.append(L[k])
		 k range(n) range n if i>>k&1:
				if j>>k&1:
					x.append(L[k])
				else:
					y.append(L[k])
			else:
				if j>>k&1:
					z.append(L[k])
		 i>>k&1 i>>k i k 1 if j>>k&1:
					x.append(L[k])
				else:
					y.append(L[k])
			 j>>k&1 j>>k j k 1 x.append(L[k]) x.append x append L[k] L k y.append(L[k]) y.append y append L[k] L k if j>>k&1:
					z.append(L[k])
		 j>>k&1 j>>k j k 1 z.append(L[k]) z.append z append L[k] L k res1=abs(sum(x)-a)+abs(sum(y)-b)+abs(sum(z)-c) res1 abs(sum(x)-a)+abs(sum(y)-b)+abs(sum(z)-c) abs(sum(x)-a)+abs(sum(y)-b) abs(sum(x)-a) abs sum(x)-a sum(x) sum x a abs(sum(y)-b) abs sum(y)-b sum(y) sum y b abs(sum(z)-c) abs sum(z)-c sum(z) sum z c if len(x)==0 or len(y)==0 or len(z)==0:
			continue
	
		 len(x)==0 or len(y)==0 or len(z)==0 len(x)==0 or len(y)==0 len(x)==0 len(x) len x 0 len(y)==0 len(y) len y 0 len(z)==0 len(z) len z 0 continue if len(x)>1:
			res1+=10*(len(x)-1)
		 len(x)>1 len(x) len x 1 res1+=10*(len(x)-1) res1 10*(len(x)-1) 10 len(x)-1 len(x) len x 1 if len(y)>1:
			res1+=10*(len(y)-1)
		 len(y)>1 len(y) len y 1 res1+=10*(len(y)-1) res1 10*(len(y)-1) 10 len(y)-1 len(y) len y 1 if len(z)>1:
			res1+=10*(len(z)-1)				
		 len(z)>1 len(z) len z 1 res1+=10*(len(z)-1) res1 10*(len(z)-1) 10 len(z)-1 len(z) len z 1 res2=min(res1,res2) res2 min(res1,res2) min res1 res2 print(res2) print res2 c=map(int,input().split()) map(int,input().split()) c n,a,b,c=map(int,input().split()) map(int,input().split()) n res1+=10*(len(y)-1) 10*(len(y)-1) res1 L=[int(input()) for _ in range(n)] [int(input()) for _ in range(n)] L res2=min(res1,res2) min(res1,res2) res2 y=[] [] y b,c=map(int,input().split()) map(int,input().split()) b res1=abs(sum(x)-a)+abs(sum(y)-b)+abs(sum(z)-c) abs(sum(x)-a)+abs(sum(y)-b)+abs(sum(z)-c) res1 z=[] [] z x=[] [] x res2=1000000000 1000000000 res2 res1+=10*(len(z)-1) 10*(len(z)-1) res1 a,b,c=map(int,input().split()) map(int,input().split()) a res1+=10*(len(x)-1) 10*(len(x)-1) res1
n,a,b,c=map(int,input().split())
L=[int(input()) for _ in range(n)]

res2=1000000000

for i in range(2**n-1):
	for j in range(2**n-1):
		x=[]
		y=[]
		z=[]
		for k in range(n):
			
			if i>>k&1:
				if j>>k&1:
					x.append(L[k])
				else:
					y.append(L[k])
			else:
				if j>>k&1:
					z.append(L[k])
		res1=abs(sum(x)-a)+abs(sum(y)-b)+abs(sum(z)-c)
		
		if len(x)==0 or len(y)==0 or len(z)==0:
			continue
	
		if len(x)>1:
			res1+=10*(len(x)-1)
		if len(y)>1:
			res1+=10*(len(y)-1)
		if len(z)>1:
			res1+=10*(len(z)-1)				
		res2=min(res1,res2)

print(res2)