import itertools

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

l = [int(input()) for _ in range(N)]

ans = 10**10
# [竹1の選択, 竹2の選択, ..., 竹Nの選択]
# 4**8==65536
for x in itertools.product([0, 1, 2, 3], repeat=N):
    # [不使用の竹の合計長さ、Aに使用する竹の合計長さ、Bに...、Cに...]
    bamboo = [0] * 4
    tmp = 0
    for i in range(N):
        # 始めて選ぶ場合はコストがかからない
        if x[i] in [1, 2, 3] and bamboo[x[i]] > 0:
            tmp += 10
        bamboo[x[i]] += l[i]

    # A,B,Cそれぞれについて、1本以上使う必要がある
    if 0 in bamboo[1:]:
        continue
    # 延長魔法 or 短縮魔法で調整
    tmp += abs(bamboo[1] - A) + abs(bamboo[2] - B) + abs(bamboo[3] - C)

    ans = min(ans, tmp)

print(ans) import itertools itertools 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 x in itertools.product([0, 1, 2, 3], repeat=N):
    # [不使用の竹の合計長さ、Aに使用する竹の合計長さ、Bに...、Cに...]
    bamboo = [0] * 4
    tmp = 0
    for i in range(N):
        # 始めて選ぶ場合はコストがかからない
        if x[i] in [1, 2, 3] and bamboo[x[i]] > 0:
            tmp += 10
        bamboo[x[i]] += l[i]

    # A,B,Cそれぞれについて、1本以上使う必要がある
    if 0 in bamboo[1:]:
        continue
    # 延長魔法 or 短縮魔法で調整
    tmp += abs(bamboo[1] - A) + abs(bamboo[2] - B) + abs(bamboo[3] - C)

    ans = min(ans, tmp) x itertools.product([0, 1, 2, 3], repeat=N) itertools.product itertools product [0, 1, 2, 3] 0 1 2 3 repeat=N repeat N bamboo = [0] * 4 bamboo [0] * 4 [0] 0 4 tmp = 0 tmp 0 for i in range(N):
        # 始めて選ぶ場合はコストがかからない
        if x[i] in [1, 2, 3] and bamboo[x[i]] > 0:
            tmp += 10
        bamboo[x[i]] += l[i]

    # A,B,Cそれぞれについて、1本以上使う必要がある
     i range(N) range N if x[i] in [1, 2, 3] and bamboo[x[i]] > 0:
            tmp += 10
         x[i] in [1, 2, 3] and bamboo[x[i]] > 0 x[i] in [1, 2, 3] x[i] x i [1, 2, 3] 1 2 3 bamboo[x[i]] > 0 bamboo[x[i]] bamboo x[i] x i 0 tmp += 10 tmp 10 bamboo[x[i]] += l[i] bamboo[x[i]] bamboo x[i] x i l[i] l i if 0 in bamboo[1:]:
        continue
    # 延長魔法 or 短縮魔法で調整
     0 in bamboo[1:] 0 bamboo[1:] bamboo 1: 1 continue tmp += abs(bamboo[1] - A) + abs(bamboo[2] - B) + abs(bamboo[3] - C) tmp abs(bamboo[1] - A) + abs(bamboo[2] - B) + abs(bamboo[3] - C) abs(bamboo[1] - A) + abs(bamboo[2] - B) abs(bamboo[1] - A) abs bamboo[1] - A bamboo[1] bamboo 1 A abs(bamboo[2] - B) abs bamboo[2] - B bamboo[2] bamboo 2 B abs(bamboo[3] - C) abs bamboo[3] - C bamboo[3] bamboo 3 C ans = min(ans, tmp) ans min(ans, tmp) min ans tmp print(ans) print ans C = map(int, input().split()) map(int, input().split()) C tmp = 0 0 tmp tmp += 10 10 tmp N, A, B, C = map(int, input().split()) map(int, input().split()) N ans = 10**10 10**10 ans bamboo = [0] * 4 [0] * 4 bamboo ans = min(ans, tmp) min(ans, tmp) ans l = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] l tmp += abs(bamboo[1] - A) + abs(bamboo[2] - B) + abs(bamboo[3] - C) abs(bamboo[1] - A) + abs(bamboo[2] - B) + abs(bamboo[3] - C) tmp A, B, C = map(int, input().split()) map(int, input().split()) A B, C = map(int, input().split()) map(int, input().split()) B
import itertools

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

l = [int(input()) for _ in range(N)]

ans = 10**10
# [竹1の選択, 竹2の選択, ..., 竹Nの選択]
# 4**8==65536
for x in itertools.product([0, 1, 2, 3], repeat=N):
    # [不使用の竹の合計長さ、Aに使用する竹の合計長さ、Bに...、Cに...]
    bamboo = [0] * 4
    tmp = 0
    for i in range(N):
        # 始めて選ぶ場合はコストがかからない
        if x[i] in [1, 2, 3] and bamboo[x[i]] > 0:
            tmp += 10
        bamboo[x[i]] += l[i]

    # A,B,Cそれぞれについて、1本以上使う必要がある
    if 0 in bamboo[1:]:
        continue
    # 延長魔法 or 短縮魔法で調整
    tmp += abs(bamboo[1] - A) + abs(bamboo[2] - B) + abs(bamboo[3] - C)

    ans = min(ans, tmp)

print(ans)
