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

L = []

for i in range(N):

  L.append(int(eval(input())))

MP = float('inf')

n = 4  

def Base_10_to_n(X,n):

  if (int(X/n)):

    return Base_10_to_n(int(X/n),n)+str(X%n)

  return str(X%n)



for X in range(4**N):

  STR = Base_10_to_n(X,n).zfill(N)

  nU = []

  uA = []

  uB = []

  uC = []

  SUBMP = 0

  for l in range(N):

    if STR[l] == '0':

      nU.append(L[l])

    elif STR[l] == '1':

      uA.append(L[l])

    elif STR[l] == '2':

      uB.append(L[l])

    else:

      uC.append(L[l])

    if len(uA) != 0 and len(uB) != 0 and len(uC) != 0:

      SUBMP = (len(uA)+len(uB)+len(uC)-3)*10+abs(sum(uA)-A)+abs(sum(uB)-B)+abs(sum(uC)-C)

      if SUBMP <= MP:

        MP = SUBMP

print(MP)
N,A,B,C = list(map(int,input().split()))

L = []

for i in range(N):

  L.append(int(eval(input())))

def Base_10_to_n(X,n):

  if (int(X/n)):

    return Base_10_to_n(int(X/n),n)+str(X%n)

  return str(X%n)

n = 4

ans = float('inf')

for X in range(n**N):

  STR = Base_10_to_n(X,n).zfill(N)

  cur = 0

  TAKEA = 0

  TAKEB = 0

  TAKEC = 0

  for i in range(len(STR)):

    if STR[i] == '1':

      TAKEA += L[i]

      cur += 10

    elif STR[i] == '2':

      TAKEB += L[i]

      cur += 10

    elif STR[i] == '3':

      TAKEC += L[i]

      cur += 10

  if TAKEA != 0 and TAKEB != 0 and TAKEC != 0:

    cur += abs(TAKEA-A)+abs(TAKEB-B)+abs(TAKEC-C)

    cur -= 30

    if cur <= ans:

      ans = cur

print(ans)
N, A, B, C = list(map(int, input().split()))
L = []
for i in range(N):
    L.append(int(eval(input())))
MP = float("inf")
n = 4


def Base_10_to_n(X, n):
    if int(X / n):
        return Base_10_to_n(int(X / n), n) + str(X % n)
    return str(X % n)


for X in range(4**N):
    STR = Base_10_to_n(X, n).zfill(N)
    nU = []
    uA = []
    uB = []
    uC = []
    SUBMP = 0
    for l in range(N):
        if STR[l] == "0":
            nU.append(L[l])
        elif STR[l] == "1":
            uA.append(L[l])
        elif STR[l] == "2":
            uB.append(L[l])
        else:
            uC.append(L[l])
        if len(uA) != 0 and len(uB) != 0 and len(uC) != 0:
            SUBMP = (
                (len(uA) + len(uB) + len(uC) - 3) * 10
                + abs(sum(uA) - A)
                + abs(sum(uB) - B)
                + abs(sum(uC) - C)
            )
            if SUBMP <= MP:
                MP = SUBMP
print(MP)

N, A, B, C = list(map(int, input().split()))
L = []
for i in range(N):
    L.append(int(eval(input())))


def Base_10_to_n(X, n):
    if int(X / n):
        return Base_10_to_n(int(X / n), n) + str(X % n)
    return str(X % n)


n = 4
ans = float("inf")
for X in range(n**N):
    STR = Base_10_to_n(X, n).zfill(N)
    cur = 0
    TAKEA = 0
    TAKEB = 0
    TAKEC = 0
    for i in range(len(STR)):
        if STR[i] == "1":
            TAKEA += L[i]
            cur += 10
        elif STR[i] == "2":
            TAKEB += L[i]
            cur += 10
        elif STR[i] == "3":
            TAKEC += L[i]
            cur += 10
    if TAKEA != 0 and TAKEB != 0 and TAKEC != 0:
        cur += abs(TAKEA - A) + abs(TAKEB - B) + abs(TAKEC - C)
        cur -= 30
        if cur <= ans:
            ans = cur
print(ans)

-MP = float("inf") -n = 4 -for X in range(4**N): +n = 4 +ans = float("inf") +for X in range(n**N): -    nU = [] -    uA = [] -    uB = [] -    uC = [] -    SUBMP = 0 -    for l in range(N): -        if STR[l] == "0": -            nU.append(L[l]) -        elif STR[l] == "1": -            uA.append(L[l]) -        elif STR[l] == "2": -            uB.append(L[l]) -        else: -            uC.append(L[l]) -        if len(uA) != 0 and len(uB) != 0 and len(uC) != 0: -            SUBMP = ( -                (len(uA) + len(uB) + len(uC) - 3) * 10 -                + abs(sum(uA) - A) -                + abs(sum(uB) - B) -                + abs(sum(uC) - C) -            ) -            if SUBMP <= MP: -                MP = SUBMP -print(MP) +    cur = 0 +    TAKEA = 0 +    TAKEB = 0 +    TAKEC = 0 +    for i in range(len(STR)): +        if STR[i] == "1": +            TAKEA += L[i] +            cur += 10 +        elif STR[i] == "2": +            TAKEB += L[i] +            cur += 10 +        elif STR[i] == "3": +            TAKEC += L[i] +            cur += 10 +    if TAKEA != 0 and TAKEB != 0 and TAKEC != 0: +        cur += abs(TAKEA - A) + abs(TAKEB - B) + abs(TAKEC - C) +        cur -= 30 +        if cur <= ans: +            ans = cur +print(ans)