import itertools

n, *abc = map(int, input().split())
llst = [int(input()) for _ in range(n)]

ans = 10 ** 10
for abc_lst in itertools.product(range(4), repeat = n):
    tmp = 0
    labc = [[0, 0] for _ in range(3)]
    for i in range(n):
        pos = abc_lst[i]
        if pos == 3:
            continue
        labc[pos][0] += llst[i]
        labc[pos][1] += 1
    if [0, 0] in labc:
        continue
    for i in range(3):
        tmp += abs(abc[i] - labc[i][0])
        tmp += 10 * (labc[i][1] - 1)
    ans = min(ans, tmp)
print(ans) import itertools itertools n, *abc = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split *abc abc int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input llst = [int(input()) for _ in range(n)] llst [int(input()) for _ in range(n)] ans = 10 ** 10 ans 10 ** 10 10 10 for abc_lst in itertools.product(range(4), repeat = n):
    tmp = 0
    labc = [[0, 0] for _ in range(3)]
    for i in range(n):
        pos = abc_lst[i]
        if pos == 3:
            continue
        labc[pos][0] += llst[i]
        labc[pos][1] += 1
    if [0, 0] in labc:
        continue
    for i in range(3):
        tmp += abs(abc[i] - labc[i][0])
        tmp += 10 * (labc[i][1] - 1)
    ans = min(ans, tmp) abc_lst itertools.product(range(4), repeat = n) itertools.product itertools product range(4) range 4 repeat = n repeat n tmp = 0 tmp 0 [0, 0] for _ in range(3) for _ in range(3) _ range(3) range 3 for _ in range(3) [0, 0] 0 0 labc = [[0, 0] for _ in range(3)] labc [[0, 0] for _ in range(3)] for i in range(n):
        pos = abc_lst[i]
        if pos == 3:
            continue
        labc[pos][0] += llst[i]
        labc[pos][1] += 1
     i range(n) range n pos = abc_lst[i] pos abc_lst[i] abc_lst i if pos == 3:
            continue
         pos == 3 pos 3 continue labc[pos][0] += llst[i] labc[pos][0] [pos] labc pos 0 llst[i] llst i labc[pos][1] += 1 labc[pos][1] [pos] labc pos 1 1 if [0, 0] in labc:
        continue
     [0, 0] in labc [0, 0] 0 0 labc continue for i in range(3):
        tmp += abs(abc[i] - labc[i][0])
        tmp += 10 * (labc[i][1] - 1)
     i range(3) range 3 tmp += abs(abc[i] - labc[i][0]) tmp abs(abc[i] - labc[i][0]) abs abc[i] - labc[i][0] abc[i] abc i labc[i][0] [i] labc i 0 tmp += 10 * (labc[i][1] - 1) tmp 10 * (labc[i][1] - 1) 10 labc[i][1] - 1 labc[i][1] [i] labc i 1 1 ans = min(ans, tmp) ans min(ans, tmp) min ans tmp print(ans) print ans tmp = 0 0 tmp llst = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] llst tmp += 10 * (labc[i][1] - 1) 10 * (labc[i][1] - 1) tmp ans = min(ans, tmp) min(ans, tmp) ans n, *abc = map(int, input().split()) map(int, input().split()) n pos = abc_lst[i] abc_lst[i] pos labc = [[0, 0] for _ in range(3)] [[0, 0] for _ in range(3)] labc ans = 10 ** 10 10 ** 10 ans tmp += abs(abc[i] - labc[i][0]) abs(abc[i] - labc[i][0]) tmp
import itertools

n, *abc = map(int, input().split())
llst = [int(input()) for _ in range(n)]

ans = 10 ** 10
for abc_lst in itertools.product(range(4), repeat = n):
    tmp = 0
    labc = [[0, 0] for _ in range(3)]
    for i in range(n):
        pos = abc_lst[i]
        if pos == 3:
            continue
        labc[pos][0] += llst[i]
        labc[pos][1] += 1
    if [0, 0] in labc:
        continue
    for i in range(3):
        tmp += abs(abc[i] - labc[i][0])
        tmp += 10 * (labc[i][1] - 1)
    ans = min(ans, tmp)
print(ans)