n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]
ans = 10**6
for i in range(4**n):
  pattern = [0]*n
  for j in range(n):
    pattern[j] = ((i >> j*2) & 3)
  bamboo = [0]*4
  for j in range(n):
    bamboo[pattern[j]] += l[j]
  if bamboo[1]*bamboo[2]*bamboo[3]==0:
    continue
  time = pattern.count(1)*10+pattern.count(2)*10+pattern.count(3)*10-30+abs(bamboo[1]-a)+abs(bamboo[2]-b)+abs(bamboo[3]-c)
  if ans > time:
    ans = time
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)] ans = 10**6 ans 10**6 10 6 for i in range(4**n):
  pattern = [0]*n
  for j in range(n):
    pattern[j] = ((i >> j*2) & 3)
  bamboo = [0]*4
  for j in range(n):
    bamboo[pattern[j]] += l[j]
  if bamboo[1]*bamboo[2]*bamboo[3]==0:
    continue
  time = pattern.count(1)*10+pattern.count(2)*10+pattern.count(3)*10-30+abs(bamboo[1]-a)+abs(bamboo[2]-b)+abs(bamboo[3]-c)
  if ans > time:
    ans = time i range(4**n) range 4**n 4 n pattern = [0]*n pattern [0]*n [0] 0 n for j in range(n):
    pattern[j] = ((i >> j*2) & 3)
   j range(n) range n pattern[j] = ((i >> j*2) & 3) pattern[j] pattern j (i >> j*2) & 3 i >> j*2 i j*2 j 2 3 bamboo = [0]*4 bamboo [0]*4 [0] 0 4 for j in range(n):
    bamboo[pattern[j]] += l[j]
   j range(n) range n bamboo[pattern[j]] += l[j] bamboo[pattern[j]] bamboo pattern[j] pattern j l[j] l j if bamboo[1]*bamboo[2]*bamboo[3]==0:
    continue
   bamboo[1]*bamboo[2]*bamboo[3]==0 bamboo[1]*bamboo[2]*bamboo[3] bamboo[1]*bamboo[2] bamboo[1] bamboo 1 bamboo[2] bamboo 2 bamboo[3] bamboo 3 0 continue time = pattern.count(1)*10+pattern.count(2)*10+pattern.count(3)*10-30+abs(bamboo[1]-a)+abs(bamboo[2]-b)+abs(bamboo[3]-c) time pattern.count(1)*10+pattern.count(2)*10+pattern.count(3)*10-30+abs(bamboo[1]-a)+abs(bamboo[2]-b)+abs(bamboo[3]-c) pattern.count(1)*10+pattern.count(2)*10+pattern.count(3)*10-30+abs(bamboo[1]-a)+abs(bamboo[2]-b) pattern.count(1)*10+pattern.count(2)*10+pattern.count(3)*10-30+abs(bamboo[1]-a) pattern.count(1)*10+pattern.count(2)*10+pattern.count(3)*10-30 pattern.count(1)*10+pattern.count(2)*10+pattern.count(3)*10 pattern.count(1)*10+pattern.count(2)*10 pattern.count(1)*10 pattern.count(1) pattern.count pattern count 1 10 pattern.count(2)*10 pattern.count(2) pattern.count pattern count 2 10 pattern.count(3)*10 pattern.count(3) pattern.count pattern count 3 10 30 abs(bamboo[1]-a) abs bamboo[1]-a bamboo[1] bamboo 1 a abs(bamboo[2]-b) abs bamboo[2]-b bamboo[2] bamboo 2 b abs(bamboo[3]-c) abs bamboo[3]-c bamboo[3] bamboo 3 c if ans > time:
    ans = time ans > time ans time ans = time ans time print(ans) print ans pattern = [0]*n [0]*n pattern c = map(int,input().split()) map(int,input().split()) c n,a,b,c = map(int,input().split()) map(int,input().split()) n b,c = map(int,input().split()) map(int,input().split()) b time = pattern.count(1)*10+pattern.count(2)*10+pattern.count(3)*10-30+abs(bamboo[1]-a)+abs(bamboo[2]-b)+abs(bamboo[3]-c) pattern.count(1)*10+pattern.count(2)*10+pattern.count(3)*10-30+abs(bamboo[1]-a)+abs(bamboo[2]-b)+abs(bamboo[3]-c) time ans = time time ans ans = 10**6 10**6 ans a,b,c = map(int,input().split()) map(int,input().split()) a l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l bamboo = [0]*4 [0]*4 bamboo
n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]
ans = 10**6
for i in range(4**n):
  pattern = [0]*n
  for j in range(n):
    pattern[j] = ((i >> j*2) & 3)
  bamboo = [0]*4
  for j in range(n):
    bamboo[pattern[j]] += l[j]
  if bamboo[1]*bamboo[2]*bamboo[3]==0:
    continue
  time = pattern.count(1)*10+pattern.count(2)*10+pattern.count(3)*10-30+abs(bamboo[1]-a)+abs(bamboo[2]-b)+abs(bamboo[3]-c)
  if ans > time:
    ans = time
print(ans)