from itertools import product

N, A, B, C = map(int, input().split(' '))
L = [int(input()) for _ in range(N)]

ans = 10 ** 9
for groups in product(range(4), repeat=N):
    length_a = 0
    length_b = 0
    length_c = 0
    cost_a = -10
    cost_b = -10
    cost_c = -10

    for group, length in zip(groups, L):
        if group == 1:
            length_a += length
            cost_a += 10
        elif group == 2:
            length_b += length
            cost_b += 10
        elif group == 3:
            length_c += length
            cost_c += 10

    if 0 in {length_a, length_b, length_c}:
        continue

    ans = min(ans, sum([
        abs(A - length_a),
        abs(B - length_b),
        abs(C - length_c),
        cost_a,
        cost_b,
        cost_c,
    ]))

print(ans) from itertools import product 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 ** 9 ans 10 ** 9 10 9 for groups in product(range(4), repeat=N):
    length_a = 0
    length_b = 0
    length_c = 0
    cost_a = -10
    cost_b = -10
    cost_c = -10

    for group, length in zip(groups, L):
        if group == 1:
            length_a += length
            cost_a += 10
        elif group == 2:
            length_b += length
            cost_b += 10
        elif group == 3:
            length_c += length
            cost_c += 10

    if 0 in {length_a, length_b, length_c}:
        continue

    ans = min(ans, sum([
        abs(A - length_a),
        abs(B - length_b),
        abs(C - length_c),
        cost_a,
        cost_b,
        cost_c,
    ])) groups product(range(4), repeat=N) product range(4) range 4 repeat=N repeat N length_a = 0 length_a 0 length_b = 0 length_b 0 length_c = 0 length_c 0 cost_a = -10 cost_a -10 cost_b = -10 cost_b -10 cost_c = -10 cost_c -10 for group, length in zip(groups, L):
        if group == 1:
            length_a += length
            cost_a += 10
        elif group == 2:
            length_b += length
            cost_b += 10
        elif group == 3:
            length_c += length
            cost_c += 10

     group length zip(groups, L) zip groups L if group == 1:
            length_a += length
            cost_a += 10
        elif group == 2:
            length_b += length
            cost_b += 10
        elif group == 3:
            length_c += length
            cost_c += 10

     group == 1 group 1 length_a += length length_a length cost_a += 10 cost_a 10 elif group == 2:
            length_b += length
            cost_b += 10
         group == 2 group 2 length_b += length length_b length cost_b += 10 cost_b 10 elif group == 3:
            length_c += length
            cost_c += 10

     group == 3 group 3 length_c += length length_c length cost_c += 10 cost_c 10 if 0 in {length_a, length_b, length_c}:
        continue

     0 in {length_a, length_b, length_c} 0 {length_a, length_b, length_c} continue ans = min(ans, sum([
        abs(A - length_a),
        abs(B - length_b),
        abs(C - length_c),
        cost_a,
        cost_b,
        cost_c,
    ])) ans min(ans, sum([
        abs(A - length_a),
        abs(B - length_b),
        abs(C - length_c),
        cost_a,
        cost_b,
        cost_c,
    ])) min ans sum([
        abs(A - length_a),
        abs(B - length_b),
        abs(C - length_c),
        cost_a,
        cost_b,
        cost_c,
    ]) sum [
        abs(A - length_a),
        abs(B - length_b),
        abs(C - length_c),
        cost_a,
        cost_b,
        cost_c,
    ] abs(A - length_a) abs A - length_a A length_a abs(B - length_b) abs B - length_b B length_b abs(C - length_c) abs C - length_c C length_c cost_a cost_b cost_c print(ans) print ans cost_c = -10 -10 cost_c L = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] L C = map(int, input().split(' ')) map(int, input().split(' ')) C length_c += length length length_c cost_a += 10 10 cost_a cost_c += 10 10 cost_c A, B, C = map(int, input().split(' ')) map(int, input().split(' ')) A B, C = map(int, input().split(' ')) map(int, input().split(' ')) B length_b = 0 0 length_b length_c = 0 0 length_c N, A, B, C = map(int, input().split(' ')) map(int, input().split(' ')) N length_a += length length length_a length_b += length length length_b length_a = 0 0 length_a cost_a = -10 -10 cost_a ans = 10 ** 9 10 ** 9 ans cost_b = -10 -10 cost_b ans = min(ans, sum([
        abs(A - length_a),
        abs(B - length_b),
        abs(C - length_c),
        cost_a,
        cost_b,
        cost_c,
    ])) min(ans, sum([
        abs(A - length_a),
        abs(B - length_b),
        abs(C - length_c),
        cost_a,
        cost_b,
        cost_c,
    ])) ans cost_b += 10 10 cost_b
from itertools import product

N, A, B, C = map(int, input().split(' '))
L = [int(input()) for _ in range(N)]

ans = 10 ** 9
for groups in product(range(4), repeat=N):
    length_a = 0
    length_b = 0
    length_c = 0
    cost_a = -10
    cost_b = -10
    cost_c = -10

    for group, length in zip(groups, L):
        if group == 1:
            length_a += length
            cost_a += 10
        elif group == 2:
            length_b += length
            cost_b += 10
        elif group == 3:
            length_c += length
            cost_c += 10

    if 0 in {length_a, length_b, length_c}:
        continue

    ans = min(ans, sum([
        abs(A - length_a),
        abs(B - length_b),
        abs(C - length_c),
        cost_a,
        cost_b,
        cost_c,
    ]))

print(ans)
