n,a,b,c=map(int,input().split())
bam=[]
for i in range(n):
  bam.append(int(input()))
def base10toN(num, base):
    converted_string, modstring = "", ""
    currentnum = num
    if not num:
        return '0'
    while currentnum:
        mod = currentnum % base
        currentnum = currentnum // base
        converted_string = chr(48 + mod + 7*(mod > 10)) + converted_string
    return converted_string
ans=10**18
for i in range(4**n):
  s=base10toN(i, 4)
  slist=[]
  for i in range(len(s)):
    slist.append(s[i])
  slist.reverse()
  for i in range(n-len(s)):
    slist.append('0')
  slist.reverse()
  s1=[]
  s2=[]
  s3=[]
  for i in range(n):
    if slist[i]=='1':
      s1.append(bam[i])
    if slist[i]=='2':
      s2.append(bam[i])
    if slist[i]=='3':
      s3.append(bam[i])
  if len(s1)==0 or len(s2)==0 or len(s3)==0:
    continue
  anscan=abs(sum(s1)-a)+abs(sum(s2)-b)+abs(sum(s3)-c)+10*(len(s1)-1)+10*(len(s2)-1)+10*(len(s3)-1)
  ans=min(ans,anscan)
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 bam=[] bam [] for i in range(n):
  bam.append(int(input())) i range(n) range n bam.append(int(input())) bam.append bam append int(input()) int input() input def base10toN(num, base):
    converted_string, modstring = "", ""
    currentnum = num
    if not num:
        return '0'
    while currentnum:
        mod = currentnum % base
        currentnum = currentnum // base
        converted_string = chr(48 + mod + 7*(mod > 10)) + converted_string
    return converted_string base10toN converted_string, modstring = "", "" converted_string "" modstring "" currentnum = num currentnum num if not num:
        return '0'
     not num num return '0' '0' while currentnum:
        mod = currentnum % base
        currentnum = currentnum // base
        converted_string = chr(48 + mod + 7*(mod > 10)) + converted_string
     currentnum mod = currentnum % base mod currentnum % base currentnum base currentnum = currentnum // base currentnum currentnum // base currentnum base converted_string = chr(48 + mod + 7*(mod > 10)) + converted_string converted_string chr(48 + mod + 7*(mod > 10)) + converted_string chr(48 + mod + 7*(mod > 10)) chr 48 + mod + 7*(mod > 10) 48 + mod 48 mod 7*(mod > 10) 7 mod > 10 mod 10 converted_string return converted_string converted_string num num base base ans=10**18 ans 10**18 10 18 for i in range(4**n):
  s=base10toN(i, 4)
  slist=[]
  for i in range(len(s)):
    slist.append(s[i])
  slist.reverse()
  for i in range(n-len(s)):
    slist.append('0')
  slist.reverse()
  s1=[]
  s2=[]
  s3=[]
  for i in range(n):
    if slist[i]=='1':
      s1.append(bam[i])
    if slist[i]=='2':
      s2.append(bam[i])
    if slist[i]=='3':
      s3.append(bam[i])
  if len(s1)==0 or len(s2)==0 or len(s3)==0:
    continue
  anscan=abs(sum(s1)-a)+abs(sum(s2)-b)+abs(sum(s3)-c)+10*(len(s1)-1)+10*(len(s2)-1)+10*(len(s3)-1)
  ans=min(ans,anscan) i range(4**n) range 4**n 4 n s=base10toN(i, 4) s base10toN(i, 4) base10toN i 4 slist=[] slist [] for i in range(len(s)):
    slist.append(s[i])
   i range(len(s)) range len(s) len s slist.append(s[i]) slist.append slist append s[i] s i slist.reverse() slist.reverse slist reverse for i in range(n-len(s)):
    slist.append('0')
   i range(n-len(s)) range n-len(s) n len(s) len s slist.append('0') slist.append slist append '0' slist.reverse() slist.reverse slist reverse s1=[] s1 [] s2=[] s2 [] s3=[] s3 [] for i in range(n):
    if slist[i]=='1':
      s1.append(bam[i])
    if slist[i]=='2':
      s2.append(bam[i])
    if slist[i]=='3':
      s3.append(bam[i])
   i range(n) range n if slist[i]=='1':
      s1.append(bam[i])
     slist[i]=='1' slist[i] slist i '1' s1.append(bam[i]) s1.append s1 append bam[i] bam i if slist[i]=='2':
      s2.append(bam[i])
     slist[i]=='2' slist[i] slist i '2' s2.append(bam[i]) s2.append s2 append bam[i] bam i if slist[i]=='3':
      s3.append(bam[i])
   slist[i]=='3' slist[i] slist i '3' s3.append(bam[i]) s3.append s3 append bam[i] bam i if len(s1)==0 or len(s2)==0 or len(s3)==0:
    continue
   len(s1)==0 or len(s2)==0 or len(s3)==0 len(s1)==0 or len(s2)==0 len(s1)==0 len(s1) len s1 0 len(s2)==0 len(s2) len s2 0 len(s3)==0 len(s3) len s3 0 continue anscan=abs(sum(s1)-a)+abs(sum(s2)-b)+abs(sum(s3)-c)+10*(len(s1)-1)+10*(len(s2)-1)+10*(len(s3)-1) anscan abs(sum(s1)-a)+abs(sum(s2)-b)+abs(sum(s3)-c)+10*(len(s1)-1)+10*(len(s2)-1)+10*(len(s3)-1) abs(sum(s1)-a)+abs(sum(s2)-b)+abs(sum(s3)-c)+10*(len(s1)-1)+10*(len(s2)-1) abs(sum(s1)-a)+abs(sum(s2)-b)+abs(sum(s3)-c)+10*(len(s1)-1) abs(sum(s1)-a)+abs(sum(s2)-b)+abs(sum(s3)-c) abs(sum(s1)-a)+abs(sum(s2)-b) abs(sum(s1)-a) abs sum(s1)-a sum(s1) sum s1 a abs(sum(s2)-b) abs sum(s2)-b sum(s2) sum s2 b abs(sum(s3)-c) abs sum(s3)-c sum(s3) sum s3 c 10*(len(s1)-1) 10 len(s1)-1 len(s1) len s1 1 10*(len(s2)-1) 10 len(s2)-1 len(s2) len s2 1 10*(len(s3)-1) 10 len(s3)-1 len(s3) len s3 1 ans=min(ans,anscan) ans min(ans,anscan) min ans anscan print(ans) print ans ans=min(ans,anscan) min(ans,anscan) ans s=base10toN(i, 4) base10toN(i, 4) s s1=[] [] s1 anscan=abs(sum(s1)-a)+abs(sum(s2)-b)+abs(sum(s3)-c)+10*(len(s1)-1)+10*(len(s2)-1)+10*(len(s3)-1) abs(sum(s1)-a)+abs(sum(s2)-b)+abs(sum(s3)-c)+10*(len(s1)-1)+10*(len(s2)-1)+10*(len(s3)-1) anscan bam=[] [] bam ans=10**18 10**18 ans a,b,c=map(int,input().split()) map(int,input().split()) a slist=[] [] slist s3=[] [] s3 def base10toN(num, base):
    converted_string, modstring = "", ""
    currentnum = num
    if not num:
        return '0'
    while currentnum:
        mod = currentnum % base
        currentnum = currentnum // base
        converted_string = chr(48 + mod + 7*(mod > 10)) + converted_string
    return converted_string def base10toN(num, base):
    converted_string, modstring = "", ""
    currentnum = num
    if not num:
        return '0'
    while currentnum:
        mod = currentnum % base
        currentnum = currentnum // base
        converted_string = chr(48 + mod + 7*(mod > 10)) + converted_string
    return converted_string base10toN n,a,b,c=map(int,input().split()) map(int,input().split()) n c=map(int,input().split()) map(int,input().split()) c s2=[] [] s2 b,c=map(int,input().split()) map(int,input().split()) b
n,a,b,c=map(int,input().split())
bam=[]
for i in range(n):
  bam.append(int(input()))
def base10toN(num, base):
    converted_string, modstring = "", ""
    currentnum = num
    if not num:
        return '0'
    while currentnum:
        mod = currentnum % base
        currentnum = currentnum // base
        converted_string = chr(48 + mod + 7*(mod > 10)) + converted_string
    return converted_string
ans=10**18
for i in range(4**n):
  s=base10toN(i, 4)
  slist=[]
  for i in range(len(s)):
    slist.append(s[i])
  slist.reverse()
  for i in range(n-len(s)):
    slist.append('0')
  slist.reverse()
  s1=[]
  s2=[]
  s3=[]
  for i in range(n):
    if slist[i]=='1':
      s1.append(bam[i])
    if slist[i]=='2':
      s2.append(bam[i])
    if slist[i]=='3':
      s3.append(bam[i])
  if len(s1)==0 or len(s2)==0 or len(s3)==0:
    continue
  anscan=abs(sum(s1)-a)+abs(sum(s2)-b)+abs(sum(s3)-c)+10*(len(s1)-1)+10*(len(s2)-1)+10*(len(s3)-1)
  ans=min(ans,anscan)
print(ans)