import bisect
INF=10**18
n,*a=map(int,input().split())
l=[int(input()) for _ in range(n)]
ans=INF
for i in range(4**n):
  x=[[] for _ in range(3)]
  for j in range(n):
    if (i>>2*j)&1 and not (i>>2*j+1)&1:x[0].append(l[j])
    if not (i>>2*j)&1 and (i>>2*j+1)&1:x[1].append(l[j])
    if (i>>2*j)&1 and (i>>2*j+1)&1:x[2].append(l[j])
  cnt=0
  for j in range(3):
    if len(x[j])==0:cnt=INF
    cnt+=(len(x[j])-1)*10+abs(sum(x[j])-a[j])
  ans=min(ans,cnt)
print(ans) import bisect bisect INF=10**18 INF 10**18 10 18 n,*a=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split *a a 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=INF ans INF for i in range(4**n):
  x=[[] for _ in range(3)]
  for j in range(n):
    if (i>>2*j)&1 and not (i>>2*j+1)&1:x[0].append(l[j])
    if not (i>>2*j)&1 and (i>>2*j+1)&1:x[1].append(l[j])
    if (i>>2*j)&1 and (i>>2*j+1)&1:x[2].append(l[j])
  cnt=0
  for j in range(3):
    if len(x[j])==0:cnt=INF
    cnt+=(len(x[j])-1)*10+abs(sum(x[j])-a[j])
  ans=min(ans,cnt) i range(4**n) range 4**n 4 n [] for _ in range(3) for _ in range(3) _ range(3) range 3 for _ in range(3) [] x=[[] for _ in range(3)] x [[] for _ in range(3)] for j in range(n):
    if (i>>2*j)&1 and not (i>>2*j+1)&1:x[0].append(l[j])
    if not (i>>2*j)&1 and (i>>2*j+1)&1:x[1].append(l[j])
    if (i>>2*j)&1 and (i>>2*j+1)&1:x[2].append(l[j])
   j range(n) range n if (i>>2*j)&1 and not (i>>2*j+1)&1:x[0].append(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 if not (i>>2*j)&1 and (i>>2*j+1)&1:x[1].append(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 if (i>>2*j)&1 and (i>>2*j+1)&1:x[2].append(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 cnt=0 cnt 0 for j in range(3):
    if len(x[j])==0:cnt=INF
    cnt+=(len(x[j])-1)*10+abs(sum(x[j])-a[j])
   j range(3) range 3 if len(x[j])==0:cnt=INF
     len(x[j])==0 len(x[j]) len x[j] x j 0 cnt+=(len(x[j])-1)*10+abs(sum(x[j])-a[j]) cnt (len(x[j])-1)*10+abs(sum(x[j])-a[j]) (len(x[j])-1)*10 len(x[j])-1 len(x[j]) len x[j] x j 1 10 abs(sum(x[j])-a[j]) abs sum(x[j])-a[j] sum(x[j]) sum x[j] x j a[j] a j ans=min(ans,cnt) ans min(ans,cnt) min ans cnt print(ans) print ans INF=10**18 10**18 INF x=[[] for _ in range(3)] [[] for _ in range(3)] x ans=INF INF ans cnt=0 0 cnt cnt+=(len(x[j])-1)*10+abs(sum(x[j])-a[j]) (len(x[j])-1)*10+abs(sum(x[j])-a[j]) cnt ans=min(ans,cnt) min(ans,cnt) ans l=[int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l n,*a=map(int,input().split()) map(int,input().split()) n
import bisect
INF=10**18
n,*a=map(int,input().split())
l=[int(input()) for _ in range(n)]
ans=INF
for i in range(4**n):
  x=[[] for _ in range(3)]
  for j in range(n):
    if (i>>2*j)&1 and not (i>>2*j+1)&1:x[0].append(l[j])
    if not (i>>2*j)&1 and (i>>2*j+1)&1:x[1].append(l[j])
    if (i>>2*j)&1 and (i>>2*j+1)&1:x[2].append(l[j])
  cnt=0
  for j in range(3):
    if len(x[j])==0:cnt=INF
    cnt+=(len(x[j])-1)*10+abs(sum(x[j])-a[j])
  ans=min(ans,cnt)
print(ans)