#18:51

n,A,B,C = list(map(int,input().split()))

D = [A,B,C]

l = []

for _ in range(n):

  l.append(int(eval(input())))

l.sort(reverse=True)

def nex(time):

  for i in range(n-1,-1,-1):

    if time[i] < 3:

      time[i] += 1

      break

    else:

      time[i] = 0

  else:

    time = 'over'

  return time

#print(nex([0,0,0,0]),nex([0,3,3,3]),nex([3,3,3,3]))

can = []

time = [0 for _ in range(n)]

while time != 'over':

  ans = (n-3) * 10

  d = [0,0,0]

  for i in range(n):

    t = time[i]

    if t == 3:

      ans -= 10

    else:

      d[t] += l[i]

  if all(d[k] != 0 for k in range(3)):

    for k in range(3):

      ans += abs(D[k] - d[k])

    can.append([ans,d])

  time = nex(time)

print((min(can,key=lambda x:x[0])[0]))
n,A,B,C = list(map(int,input().split()))

D = [A,B,C]

def nex(time):

  for i in range(n):

    if time[i] < 3:

      time[i] += 1

      break

    else:

      time[i] = 0

  else:

    time = 'over'

  return time

boo = []

for _ in range(n):

  boo.append(int(eval(input())))

can = []

time = [0 for _ in range(n)]

while time != 'over':

  d = [0,0,0]

  tmp = (n-3) * 10

  for i in range(n):

    if time[i] < 3:

      d[time[i]] += boo[i]

    else:

      tmp -= 10

  for k in range(3):

    tmp += abs(D[k] - d[k])

  if d[0] * d[1] * d[2] != 0:

    can.append(tmp)

  time = nex(time)

print((min(can)))
# 18:51
n, A, B, C = list(map(int, input().split()))
D = [A, B, C]
l = []
for _ in range(n):
    l.append(int(eval(input())))
l.sort(reverse=True)


def nex(time):
    for i in range(n - 1, -1, -1):
        if time[i] < 3:
            time[i] += 1
            break
        else:
            time[i] = 0
    else:
        time = "over"
    return time


# print(nex([0,0,0,0]),nex([0,3,3,3]),nex([3,3,3,3]))
can = []
time = [0 for _ in range(n)]
while time != "over":
    ans = (n - 3) * 10
    d = [0, 0, 0]
    for i in range(n):
        t = time[i]
        if t == 3:
            ans -= 10
        else:
            d[t] += l[i]
    if all(d[k] != 0 for k in range(3)):
        for k in range(3):
            ans += abs(D[k] - d[k])
        can.append([ans, d])
    time = nex(time)
print((min(can, key=lambda x: x[0])[0]))

n, A, B, C = list(map(int, input().split()))
D = [A, B, C]


def nex(time):
    for i in range(n):
        if time[i] < 3:
            time[i] += 1
            break
        else:
            time[i] = 0
    else:
        time = "over"
    return time


boo = []
for _ in range(n):
    boo.append(int(eval(input())))
can = []
time = [0 for _ in range(n)]
while time != "over":
    d = [0, 0, 0]
    tmp = (n - 3) * 10
    for i in range(n):
        if time[i] < 3:
            d[time[i]] += boo[i]
        else:
            tmp -= 10
    for k in range(3):
        tmp += abs(D[k] - d[k])
    if d[0] * d[1] * d[2] != 0:
        can.append(tmp)
    time = nex(time)
print((min(can)))

-# 18:51 -l = [] -for _ in range(n): -    l.append(int(eval(input()))) -l.sort(reverse=True) -    for i in range(n - 1, -1, -1): +    for i in range(n): -# print(nex([0,0,0,0]),nex([0,3,3,3]),nex([3,3,3,3])) +boo = [] +for _ in range(n): +    boo.append(int(eval(input()))) -    ans = (n - 3) * 10 +    tmp = (n - 3) * 10 -        t = time[i] -        if t == 3: -            ans -= 10 +        if time[i] < 3: +            d[time[i]] += boo[i] -            d[t] += l[i] -    if all(d[k] != 0 for k in range(3)): -        for k in range(3): -            ans += abs(D[k] - d[k]) -        can.append([ans, d]) +            tmp -= 10 +    for k in range(3): +        tmp += abs(D[k] - d[k]) +    if d[0] * d[1] * d[2] != 0: +        can.append(tmp) -print((min(can, key=lambda x: x[0])[0])) +print((min(can)))