n,a,b,c=map(int,input().split())
length=[]
for i in range(n):
  k=int(input())
  length.append(k)
length=sorted(length)
x=[0,1,2,3]
ans=[]
if len(length)==3:
    for p in x:
      for q in x:
        for r in x:
            value=0
            a_length=0
            b_length=0
            c_length=0
            line=[p,q,r]
            if line.count(1)==0:
                value+=10*18
            if line.count(2)==0:
                value+=10*18
            if line.count(3)==0:
                value+=10*18
            if line.count(1)>1:
              value+=10*(line.count(1)-1)
            if line.count(2)>1:
              value+=10*(line.count(2)-1)
            if line.count(3)>1:
              value+=10*(line.count(3)-1)
            A=[i for i, y in enumerate(line) if y ==1]
            B=[i for i, y in enumerate(line) if y ==2]
            C=[i for i, y in enumerate(line) if y ==3]
            for i in A:
              a_length+=length[i]
            for i in B:
              b_length+=length[i]
            for i in C:
              c_length+=length[i]
            value+=abs(a-a_length)
            value+=abs(b-b_length)
            value+=abs(c-c_length)
            ans.append(value)
if len(length)==4:
    for p in x:
      for q in x:
        for r in x:
          for s in x:
              value=0
              a_length=0
              b_length=0
              c_length=0
              line=[p,q,r,s]
              if line.count(1)==0:
                  value+=10*18
              if line.count(2)==0:
                  value+=10*18
              if line.count(3)==0:
                  value+=10*18
              if line.count(1)>1:
                value+=10*(line.count(1)-1)
              if line.count(2)>1:
                value+=10*(line.count(2)-1)
              if line.count(3)>1:
                value+=10*(line.count(3)-1)
              A=[i for i, y in enumerate(line) if y ==1]
              B=[i for i, y in enumerate(line) if y ==2]
              C=[i for i, y in enumerate(line) if y ==3]
              for i in A:
                a_length+=length[i]
              for i in B:
                b_length+=length[i]
              for i in C:
                c_length+=length[i]
              value+=abs(a-a_length)
              value+=abs(b-b_length)
              value+=abs(c-c_length)
              ans.append(value)
if len(length)==5:
    for p in x:
      for q in x:
        for r in x:
          for s in x:
            for t in x:
                value=0
                a_length=0
                b_length=0
                c_length=0
                line=[p,q,r,s,t]
                if line.count(1)==0:
                    value+=10*18
                if line.count(2)==0:
                    value+=10*18
                if line.count(3)==0:
                    value+=10*18
                if line.count(1)>1:
                  value+=10*(line.count(1)-1)
                if line.count(2)>1:
                  value+=10*(line.count(2)-1)
                if line.count(3)>1:
                  value+=10*(line.count(3)-1)
                A=[i for i, y in enumerate(line) if y ==1]
                B=[i for i, y in enumerate(line) if y ==2]
                C=[i for i, y in enumerate(line) if y ==3]
                for i in A:
                  a_length+=length[i]
                for i in B:
                  b_length+=length[i]
                for i in C:
                  c_length+=length[i]
                value+=abs(a-a_length)
                value+=abs(b-b_length)
                value+=abs(c-c_length)
                ans.append(value)
if len(length)==6:
    for p in x:
      for q in x:
        for r in x:
          for s in x:
            for t in x:
              for u in x:
                  value=0
                  a_length=0
                  b_length=0
                  c_length=0
                  line=[p,q,r,s,t,u]
                  if line.count(1)==0:
                      value+=10*18
                  if line.count(2)==0:
                      value+=10*18
                  if line.count(3)==0:
                      value+=10*18
                  if line.count(1)>1:
                    value+=10*(line.count(1)-1)
                  if line.count(2)>1:
                    value+=10*(line.count(2)-1)
                  if line.count(3)>1:
                    value+=10*(line.count(3)-1)
                  A=[i for i, y in enumerate(line) if y ==1]
                  B=[i for i, y in enumerate(line) if y ==2]
                  C=[i for i, y in enumerate(line) if y ==3]
                  for i in A:
                    a_length+=length[i]
                  for i in B:
                    b_length+=length[i]
                  for i in C:
                    c_length+=length[i]
                  value+=abs(a-a_length)
                  value+=abs(b-b_length)
                  value+=abs(c-c_length)
                  ans.append(value)
if len(length)==7:
    for p in x:
      for q in x:
        for r in x:
          for s in x:
            for t in x:
              for u in x:
                for v in x:
                    value=0
                    a_length=0
                    b_length=0
                    c_length=0
                    line=[p,q,r,s,t,u,v]
                    if line.count(1)==0:
                        value+=10*18
                    if line.count(2)==0:
                        value+=10*18
                    if line.count(3)==0:
                        value+=10*18
                    if line.count(1)>1:
                      value+=10*(line.count(1)-1)
                    if line.count(2)>1:
                      value+=10*(line.count(2)-1)
                    if line.count(3)>1:
                      value+=10*(line.count(3)-1)
                    A=[i for i, y in enumerate(line) if y ==1]
                    B=[i for i, y in enumerate(line) if y ==2]
                    C=[i for i, y in enumerate(line) if y ==3]
                    for i in A:
                      a_length+=length[i]
                    for i in B:
                      b_length+=length[i]
                    for i in C:
                      c_length+=length[i]
                    value+=abs(a-a_length)
                    value+=abs(b-b_length)
                    value+=abs(c-c_length)
                    ans.append(value)
if len(length)==8:
    for p in x:
      for q in x:
        for r in x:
          for s in x:
            for t in x:
              for u in x:
                for v in x:
                  for w in x:
                    value=0
                    a_length=0
                    b_length=0
                    c_length=0
                    line=[p,q,r,s,t,u,v,w]
                    if line.count(1)==0:
                        value+=10*18
                    if line.count(2)==0:
                        value+=10*18
                    if line.count(3)==0:
                        value+=10*18
                    if line.count(1)>1:
                      value+=10*(line.count(1)-1)
                    if line.count(2)>1:
                      value+=10*(line.count(2)-1)
                    if line.count(3)>1:
                      value+=10*(line.count(3)-1)
                    A=[i for i, y in enumerate(line) if y ==1]
                    B=[i for i, y in enumerate(line) if y ==2]
                    C=[i for i, y in enumerate(line) if y ==3]
                    for i in A:
                      a_length+=length[i]
                    for i in B:
                      b_length+=length[i]
                    for i in C:
                      c_length+=length[i]
                    value+=abs(a-a_length)
                    value+=abs(b-b_length)
                    value+=abs(c-c_length)
                    ans.append(value)
print(min(ans))

Measured memory_bytes: 5928