n,A,B,C=map(int,input().split())
L=[0]*n
for i in range(n):
  L[i]=int(input())
ans=10**10
for i in range(2**n):
  S=format(i,"10b")
  K=[]
  for j in range(n):
    if S[-1-j]=="1":
      K.append(j)
  k=len(K)
  if len(K)<3:
    continue
  for j in range(2**k):
    SS=format(j,"10b")
    AA=[]
    for l in range(k):
      if SS[-1-l]=="1":
        AA.append(K[l])
    a=len(AA)
    if a<1 or k-2<a:
      continue
    KK=sorted(list(set(K)-set(AA)))
    kk=k-a
    for l in range(2**kk):
      SSS=format(l,"10b")
      BB=[]
      for m in range(kk):
        if SSS[-1-m]=="1":
          BB.append(KK[m])
      b=len(BB)
      if b<1 or kk-1<b:
        continue
      CC=sorted(list(set(KK)-set(BB)))
      c=len(CC)
      AAA=sum(L[AA[x]] for x in range(a))
      BBB=sum(L[BB[x]] for x in range(b))
      CCC=sum(L[CC[x]] for x in range(c))
      aans=(a+b+c-3)*10+abs(AAA-A)+abs(BBB-B)+abs(CCC-C)
      if aans<ans:
        ans=aans
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 L=[0]*n L [0]*n [0] 0 n for i in range(n):
  L[i]=int(input()) i range(n) range n L[i]=int(input()) L[i] L i int(input()) int input() input ans=10**10 ans 10**10 10 10 for i in range(2**n):
  S=format(i,"10b")
  K=[]
  for j in range(n):
    if S[-1-j]=="1":
      K.append(j)
  k=len(K)
  if len(K)<3:
    continue
  for j in range(2**k):
    SS=format(j,"10b")
    AA=[]
    for l in range(k):
      if SS[-1-l]=="1":
        AA.append(K[l])
    a=len(AA)
    if a<1 or k-2<a:
      continue
    KK=sorted(list(set(K)-set(AA)))
    kk=k-a
    for l in range(2**kk):
      SSS=format(l,"10b")
      BB=[]
      for m in range(kk):
        if SSS[-1-m]=="1":
          BB.append(KK[m])
      b=len(BB)
      if b<1 or kk-1<b:
        continue
      CC=sorted(list(set(KK)-set(BB)))
      c=len(CC)
      AAA=sum(L[AA[x]] for x in range(a))
      BBB=sum(L[BB[x]] for x in range(b))
      CCC=sum(L[CC[x]] for x in range(c))
      aans=(a+b+c-3)*10+abs(AAA-A)+abs(BBB-B)+abs(CCC-C)
      if aans<ans:
        ans=aans i range(2**n) range 2**n 2 n S=format(i,"10b") S format(i,"10b") format i "10b" K=[] K [] for j in range(n):
    if S[-1-j]=="1":
      K.append(j)
   j range(n) range n if S[-1-j]=="1":
      K.append(j)
   S[-1-j]=="1" S[-1-j] S -1-j -1 j "1" K.append(j) K.append K append j k=len(K) k len(K) len K if len(K)<3:
    continue
   len(K)<3 len(K) len K 3 continue for j in range(2**k):
    SS=format(j,"10b")
    AA=[]
    for l in range(k):
      if SS[-1-l]=="1":
        AA.append(K[l])
    a=len(AA)
    if a<1 or k-2<a:
      continue
    KK=sorted(list(set(K)-set(AA)))
    kk=k-a
    for l in range(2**kk):
      SSS=format(l,"10b")
      BB=[]
      for m in range(kk):
        if SSS[-1-m]=="1":
          BB.append(KK[m])
      b=len(BB)
      if b<1 or kk-1<b:
        continue
      CC=sorted(list(set(KK)-set(BB)))
      c=len(CC)
      AAA=sum(L[AA[x]] for x in range(a))
      BBB=sum(L[BB[x]] for x in range(b))
      CCC=sum(L[CC[x]] for x in range(c))
      aans=(a+b+c-3)*10+abs(AAA-A)+abs(BBB-B)+abs(CCC-C)
      if aans<ans:
        ans=aans j range(2**k) range 2**k 2 k SS=format(j,"10b") SS format(j,"10b") format j "10b" AA=[] AA [] for l in range(k):
      if SS[-1-l]=="1":
        AA.append(K[l])
     l range(k) range k if SS[-1-l]=="1":
        AA.append(K[l])
     SS[-1-l]=="1" SS[-1-l] SS -1-l -1 l "1" AA.append(K[l]) AA.append AA append K[l] K l a=len(AA) a len(AA) len AA if a<1 or k-2<a:
      continue
     a<1 or k-2<a a<1 a 1 k-2<a k-2 k 2 a continue KK=sorted(list(set(K)-set(AA))) KK sorted(list(set(K)-set(AA))) sorted list(set(K)-set(AA)) list set(K)-set(AA) set(K) set K set(AA) set AA kk=k-a kk k-a k a for l in range(2**kk):
      SSS=format(l,"10b")
      BB=[]
      for m in range(kk):
        if SSS[-1-m]=="1":
          BB.append(KK[m])
      b=len(BB)
      if b<1 or kk-1<b:
        continue
      CC=sorted(list(set(KK)-set(BB)))
      c=len(CC)
      AAA=sum(L[AA[x]] for x in range(a))
      BBB=sum(L[BB[x]] for x in range(b))
      CCC=sum(L[CC[x]] for x in range(c))
      aans=(a+b+c-3)*10+abs(AAA-A)+abs(BBB-B)+abs(CCC-C)
      if aans<ans:
        ans=aans l range(2**kk) range 2**kk 2 kk SSS=format(l,"10b") SSS format(l,"10b") format l "10b" BB=[] BB [] for m in range(kk):
        if SSS[-1-m]=="1":
          BB.append(KK[m])
       m range(kk) range kk if SSS[-1-m]=="1":
          BB.append(KK[m])
       SSS[-1-m]=="1" SSS[-1-m] SSS -1-m -1 m "1" BB.append(KK[m]) BB.append BB append KK[m] KK m b=len(BB) b len(BB) len BB if b<1 or kk-1<b:
        continue
       b<1 or kk-1<b b<1 b 1 kk-1<b kk-1 kk 1 b continue CC=sorted(list(set(KK)-set(BB))) CC sorted(list(set(KK)-set(BB))) sorted list(set(KK)-set(BB)) list set(KK)-set(BB) set(KK) set KK set(BB) set BB c=len(CC) c len(CC) len CC AAA=sum(L[AA[x]] for x in range(a)) AAA sum(L[AA[x]] for x in range(a)) sum L[AA[x]] L AA[x] AA x BBB=sum(L[BB[x]] for x in range(b)) BBB sum(L[BB[x]] for x in range(b)) sum L[BB[x]] L BB[x] BB x CCC=sum(L[CC[x]] for x in range(c)) CCC sum(L[CC[x]] for x in range(c)) sum L[CC[x]] L CC[x] CC x aans=(a+b+c-3)*10+abs(AAA-A)+abs(BBB-B)+abs(CCC-C) aans (a+b+c-3)*10+abs(AAA-A)+abs(BBB-B)+abs(CCC-C) (a+b+c-3)*10+abs(AAA-A)+abs(BBB-B) (a+b+c-3)*10+abs(AAA-A) (a+b+c-3)*10 a+b+c-3 a+b+c a+b a b c 3 10 abs(AAA-A) abs AAA-A AAA A abs(BBB-B) abs BBB-B BBB B abs(CCC-C) abs CCC-C CCC C if aans<ans:
        ans=aans aans<ans aans ans ans=aans ans aans print(ans) print ans SS=format(j,"10b") format(j,"10b") SS AA=[] [] AA AAA=sum(L[AA[x]] for x in range(a)) sum(L[AA[x]] for x in range(a)) AAA a=len(AA) len(AA) a K=[] [] K b=len(BB) len(BB) b k=len(K) len(K) k B,C=map(int,input().split()) map(int,input().split()) B BB=[] [] BB CC=sorted(list(set(KK)-set(BB))) sorted(list(set(KK)-set(BB))) CC n,A,B,C=map(int,input().split()) map(int,input().split()) n KK=sorted(list(set(K)-set(AA))) sorted(list(set(K)-set(AA))) KK ans=aans aans ans S=format(i,"10b") format(i,"10b") S L=[0]*n [0]*n L aans=(a+b+c-3)*10+abs(AAA-A)+abs(BBB-B)+abs(CCC-C) (a+b+c-3)*10+abs(AAA-A)+abs(BBB-B)+abs(CCC-C) aans A,B,C=map(int,input().split()) map(int,input().split()) A C=map(int,input().split()) map(int,input().split()) C ans=10**10 10**10 ans kk=k-a k-a kk CCC=sum(L[CC[x]] for x in range(c)) sum(L[CC[x]] for x in range(c)) CCC c=len(CC) len(CC) c BBB=sum(L[BB[x]] for x in range(b)) sum(L[BB[x]] for x in range(b)) BBB SSS=format(l,"10b") format(l,"10b") SSS
n,A,B,C=map(int,input().split())
L=[0]*n
for i in range(n):
  L[i]=int(input())
ans=10**10
for i in range(2**n):
  S=format(i,"10b")
  K=[]
  for j in range(n):
    if S[-1-j]=="1":
      K.append(j)
  k=len(K)
  if len(K)<3:
    continue
  for j in range(2**k):
    SS=format(j,"10b")
    AA=[]
    for l in range(k):
      if SS[-1-l]=="1":
        AA.append(K[l])
    a=len(AA)
    if a<1 or k-2<a:
      continue
    KK=sorted(list(set(K)-set(AA)))
    kk=k-a
    for l in range(2**kk):
      SSS=format(l,"10b")
      BB=[]
      for m in range(kk):
        if SSS[-1-m]=="1":
          BB.append(KK[m])
      b=len(BB)
      if b<1 or kk-1<b:
        continue
      CC=sorted(list(set(KK)-set(BB)))
      c=len(CC)
      AAA=sum(L[AA[x]] for x in range(a))
      BBB=sum(L[BB[x]] for x in range(b))
      CCC=sum(L[CC[x]] for x in range(c))
      aans=(a+b+c-3)*10+abs(AAA-A)+abs(BBB-B)+abs(CCC-C)
      if aans<ans:
        ans=aans
print(ans)