from itertools import product
from collections import Counter as ct

n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

ans = 10 ** 10
for bit in product([0, 1, 2, 3], repeat=n):
    if len(set(bit) - {0}) != 3:
        continue
    tmpa = 0
    tmpb = 0
    tmpc = 0
    for i, j in enumerate(bit):
        if j == 1:
            tmpa += l[i]
        elif j == 2:
            tmpb += l[i]
        elif j == 3:
            tmpc += l[i]
    mp = abs(a - tmpa) + abs(b - tmpb) + abs(c - tmpc)
    tmp = ct(bit)
    for i in range(1, 4):
        mp += max(0, tmp[i] - 1) * 10
    ans = min(ans, mp)
print(ans) from itertools import product from collections import Counter as ct n, a, b, c = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split a b c int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input l = [int(input()) for _ in range(n)] l [int(input()) for _ in range(n)] ans = 10 ** 10 ans 10 ** 10 10 10 for bit in product([0, 1, 2, 3], repeat=n):
    if len(set(bit) - {0}) != 3:
        continue
    tmpa = 0
    tmpb = 0
    tmpc = 0
    for i, j in enumerate(bit):
        if j == 1:
            tmpa += l[i]
        elif j == 2:
            tmpb += l[i]
        elif j == 3:
            tmpc += l[i]
    mp = abs(a - tmpa) + abs(b - tmpb) + abs(c - tmpc)
    tmp = ct(bit)
    for i in range(1, 4):
        mp += max(0, tmp[i] - 1) * 10
    ans = min(ans, mp) bit product([0, 1, 2, 3], repeat=n) product [0, 1, 2, 3] 0 1 2 3 repeat=n repeat n if len(set(bit) - {0}) != 3:
        continue
     len(set(bit) - {0}) != 3 len(set(bit) - {0}) len set(bit) - {0} set(bit) set bit {0} 3 continue tmpa = 0 tmpa 0 tmpb = 0 tmpb 0 tmpc = 0 tmpc 0 for i, j in enumerate(bit):
        if j == 1:
            tmpa += l[i]
        elif j == 2:
            tmpb += l[i]
        elif j == 3:
            tmpc += l[i]
     i j enumerate(bit) enumerate bit if j == 1:
            tmpa += l[i]
        elif j == 2:
            tmpb += l[i]
        elif j == 3:
            tmpc += l[i]
     j == 1 j 1 tmpa += l[i] tmpa l[i] l i elif j == 2:
            tmpb += l[i]
         j == 2 j 2 tmpb += l[i] tmpb l[i] l i elif j == 3:
            tmpc += l[i]
     j == 3 j 3 tmpc += l[i] tmpc l[i] l i mp = abs(a - tmpa) + abs(b - tmpb) + abs(c - tmpc) mp abs(a - tmpa) + abs(b - tmpb) + abs(c - tmpc) abs(a - tmpa) + abs(b - tmpb) abs(a - tmpa) abs a - tmpa a tmpa abs(b - tmpb) abs b - tmpb b tmpb abs(c - tmpc) abs c - tmpc c tmpc tmp = ct(bit) tmp ct(bit) ct bit for i in range(1, 4):
        mp += max(0, tmp[i] - 1) * 10
     i range(1, 4) range 1 4 mp += max(0, tmp[i] - 1) * 10 mp max(0, tmp[i] - 1) * 10 max(0, tmp[i] - 1) max 0 tmp[i] - 1 tmp[i] tmp i 1 10 ans = min(ans, mp) ans min(ans, mp) min ans mp print(ans) print ans n, a, b, c = map(int, input().split()) map(int, input().split()) n ans = min(ans, mp) min(ans, mp) ans tmpc = 0 0 tmpc a, b, c = map(int, input().split()) map(int, input().split()) a tmpa += l[i] l[i] tmpa tmpc += l[i] l[i] tmpc mp = abs(a - tmpa) + abs(b - tmpb) + abs(c - tmpc) abs(a - tmpa) + abs(b - tmpb) + abs(c - tmpc) mp tmpb = 0 0 tmpb c = map(int, input().split()) map(int, input().split()) c tmpa = 0 0 tmpa l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l ans = 10 ** 10 10 ** 10 ans b, c = map(int, input().split()) map(int, input().split()) b tmpb += l[i] l[i] tmpb tmp = ct(bit) ct(bit) tmp mp += max(0, tmp[i] - 1) * 10 max(0, tmp[i] - 1) * 10 mp
from itertools import product
from collections import Counter as ct

n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

ans = 10 ** 10
for bit in product([0, 1, 2, 3], repeat=n):
    if len(set(bit) - {0}) != 3:
        continue
    tmpa = 0
    tmpb = 0
    tmpc = 0
    for i, j in enumerate(bit):
        if j == 1:
            tmpa += l[i]
        elif j == 2:
            tmpb += l[i]
        elif j == 3:
            tmpc += l[i]
    mp = abs(a - tmpa) + abs(b - tmpb) + abs(c - tmpc)
    tmp = ct(bit)
    for i in range(1, 4):
        mp += max(0, tmp[i] - 1) * 10
    ans = min(ans, mp)
print(ans)