n,a,b,c=map(int,input().split())
l=[int(input()) for _ in range(n)]
ans=10**18
for i in range(4**n):
  la,lb,lc,ca,cb,cc=0,0,0,0,0,0
  for j in range(n):
    if (i>>2*j)&1 and not (i>>2*j+1)&1:
      ca+=1
      la+=l[j]
    if not (i>>2*j)&1 and (i>>2*j+1)&1:
      cb+=1
      lb+=l[j]
    if (i>>2*j)&1 and (i>>2*j+1)&1:
      cc+=1
      lc+=l[j]
  if ca*cb*cc:ans=min((ca+cb+cc-3)*10+abs(la-a)+abs(lb-b)+abs(lc-c),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)] ans=10**18 ans 10**18 10 18 for i in range(4**n):
  la,lb,lc,ca,cb,cc=0,0,0,0,0,0
  for j in range(n):
    if (i>>2*j)&1 and not (i>>2*j+1)&1:
      ca+=1
      la+=l[j]
    if not (i>>2*j)&1 and (i>>2*j+1)&1:
      cb+=1
      lb+=l[j]
    if (i>>2*j)&1 and (i>>2*j+1)&1:
      cc+=1
      lc+=l[j]
  if ca*cb*cc:ans=min((ca+cb+cc-3)*10+abs(la-a)+abs(lb-b)+abs(lc-c),ans) i range(4**n) range 4**n 4 n la,lb,lc,ca,cb,cc=0,0,0,0,0,0 la 0 lb 0 lc 0 ca 0 cb 0 cc 0 for j in range(n):
    if (i>>2*j)&1 and not (i>>2*j+1)&1:
      ca+=1
      la+=l[j]
    if not (i>>2*j)&1 and (i>>2*j+1)&1:
      cb+=1
      lb+=l[j]
    if (i>>2*j)&1 and (i>>2*j+1)&1:
      cc+=1
      lc+=l[j]
   j range(n) range n if (i>>2*j)&1 and not (i>>2*j+1)&1:
      ca+=1
      la+=l[j]
     (i>>2*j)&1 and not (i>>2*j+1)&1 (i>>2*j)&1 i>>2*j i 2*j 2 j 1 not (i>>2*j+1)&1 (i>>2*j+1)&1 i>>2*j+1 i 2*j+1 2*j 2 j 1 1 ca+=1 ca 1 la+=l[j] la l[j] l j if not (i>>2*j)&1 and (i>>2*j+1)&1:
      cb+=1
      lb+=l[j]
     not (i>>2*j)&1 and (i>>2*j+1)&1 not (i>>2*j)&1 (i>>2*j)&1 i>>2*j i 2*j 2 j 1 (i>>2*j+1)&1 i>>2*j+1 i 2*j+1 2*j 2 j 1 1 cb+=1 cb 1 lb+=l[j] lb l[j] l j if (i>>2*j)&1 and (i>>2*j+1)&1:
      cc+=1
      lc+=l[j]
   (i>>2*j)&1 and (i>>2*j+1)&1 (i>>2*j)&1 i>>2*j i 2*j 2 j 1 (i>>2*j+1)&1 i>>2*j+1 i 2*j+1 2*j 2 j 1 1 cc+=1 cc 1 lc+=l[j] lc l[j] l j if ca*cb*cc:ans=min((ca+cb+cc-3)*10+abs(la-a)+abs(lb-b)+abs(lc-c),an ca*cb*cc ca*cb ca cb cc print(ans) print ans cb+=1 1 cb n,a,b,c=map(int,input().split()) map(int,input().split()) n ca,cb,cc=0,0,0,0,0,0 0 ca lc,ca,cb,cc=0,0,0,0,0,0 0 lc cb,cc=0,0,0,0,0,0 0 cb c=map(int,input().split()) map(int,input().split()) c lb+=l[j] l[j] lb la+=l[j] l[j] la lb,lc,ca,cb,cc=0,0,0,0,0,0 0 lb ca+=1 1 ca la,lb,lc,ca,cb,cc=0,0,0,0,0,0 0 la cc=0,0,0,0,0,0 0 cc l=[int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l lc+=l[j] l[j] lc a,b,c=map(int,input().split()) map(int,input().split()) a b,c=map(int,input().split()) map(int,input().split()) b ans=10**18 10**18 ans cc+=1 1 cc
n,a,b,c=map(int,input().split())
l=[int(input()) for _ in range(n)]
ans=10**18
for i in range(4**n):
  la,lb,lc,ca,cb,cc=0,0,0,0,0,0
  for j in range(n):
    if (i>>2*j)&1 and not (i>>2*j+1)&1:
      ca+=1
      la+=l[j]
    if not (i>>2*j)&1 and (i>>2*j+1)&1:
      cb+=1
      lb+=l[j]
    if (i>>2*j)&1 and (i>>2*j+1)&1:
      cc+=1
      lc+=l[j]
  if ca*cb*cc:ans=min((ca+cb+cc-3)*10+abs(la-a)+abs(lb-b)+abs(lc-c),ans)
print(ans)