from itertools import product
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]
# 3:A 2:B 1:C 0:使わない
ans = float("inf")
use_list = list(product(range(4), repeat=n))
#print(use_list)
for take_use in use_list:
    a, b, c = 0, 0, 0
    count_a, count_b, count_c = 0, 0, 0
    cost = 0
    for j in range(n):
        if take_use[j] == 3:
            a += l[j]
            count_a += 1
        elif take_use[j] == 2:
            b += l[j]
            count_b += 1
        elif take_use[j] == 1:
            c += l[j]
            count_c += 1
    if count_a == 0 or count_b == 0 or count_c == 0:
        continue
    cost += (count_a-1 + count_b-1 + count_c-1)*10
    cost += abs(A-a) + abs(B-b) + abs(C-c)
    ans = min(ans, cost)
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 = float("inf") ans float("inf") float "inf" use_list = list(product(range(4), repeat=n)) use_list list(product(range(4), repeat=n)) list product(range(4), repeat=n) product range(4) range 4 repeat=n repeat n for take_use in use_list:
    a, b, c = 0, 0, 0
    count_a, count_b, count_c = 0, 0, 0
    cost = 0
    for j in range(n):
        if take_use[j] == 3:
            a += l[j]
            count_a += 1
        elif take_use[j] == 2:
            b += l[j]
            count_b += 1
        elif take_use[j] == 1:
            c += l[j]
            count_c += 1
    if count_a == 0 or count_b == 0 or count_c == 0:
        continue
    cost += (count_a-1 + count_b-1 + count_c-1)*10
    cost += abs(A-a) + abs(B-b) + abs(C-c)
    ans = min(ans, cost) take_use use_list a, b, c = 0, 0, 0 a 0 b 0 c 0 count_a, count_b, count_c = 0, 0, 0 count_a 0 count_b 0 count_c 0 cost = 0 cost 0 for j in range(n):
        if take_use[j] == 3:
            a += l[j]
            count_a += 1
        elif take_use[j] == 2:
            b += l[j]
            count_b += 1
        elif take_use[j] == 1:
            c += l[j]
            count_c += 1
     j range(n) range n if take_use[j] == 3:
            a += l[j]
            count_a += 1
        elif take_use[j] == 2:
            b += l[j]
            count_b += 1
        elif take_use[j] == 1:
            c += l[j]
            count_c += 1
     take_use[j] == 3 take_use[j] take_use j 3 a += l[j] a l[j] l j count_a += 1 count_a 1 elif take_use[j] == 2:
            b += l[j]
            count_b += 1
         take_use[j] == 2 take_use[j] take_use j 2 b += l[j] b l[j] l j count_b += 1 count_b 1 elif take_use[j] == 1:
            c += l[j]
            count_c += 1
     take_use[j] == 1 take_use[j] take_use j 1 c += l[j] c l[j] l j count_c += 1 count_c 1 if count_a == 0 or count_b == 0 or count_c == 0:
        continue
     count_a == 0 or count_b == 0 or count_c == 0 count_a == 0 or count_b == 0 count_a == 0 count_a 0 count_b == 0 count_b 0 count_c == 0 count_c 0 continue cost += (count_a-1 + count_b-1 + count_c-1)*10 cost (count_a-1 + count_b-1 + count_c-1)*10 count_a-1 + count_b-1 + count_c-1 count_a-1 + count_b-1 + count_c count_a-1 + count_b-1 count_a-1 + count_b count_a-1 count_a 1 count_b 1 count_c 1 10 cost += abs(A-a) + abs(B-b) + abs(C-c) cost abs(A-a) + abs(B-b) + abs(C-c) abs(A-a) + abs(B-b) abs(A-a) abs A-a A a abs(B-b) abs B-b B b abs(C-c) abs C-c C c ans = min(ans, cost) ans min(ans, cost) min ans cost print(ans) print ans a += l[j] l[j] a a, b, c = 0, 0, 0 0 a count_b += 1 1 count_b c += l[j] l[j] c l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l cost += abs(A-a) + abs(B-b) + abs(C-c) abs(A-a) + abs(B-b) + abs(C-c) cost B, C = map(int, input().split()) map(int, input().split()) B b += l[j] l[j] b cost += (count_a-1 + count_b-1 + count_c-1)*10 (count_a-1 + count_b-1 + count_c-1)*10 cost ans = min(ans, cost) min(ans, cost) ans n, A, B, C = map(int, input().split()) map(int, input().split()) n C = map(int, input().split()) map(int, input().split()) C count_a, count_b, count_c = 0, 0, 0 0 count_a A, B, C = map(int, input().split()) map(int, input().split()) A c = 0, 0, 0 0 c b, c = 0, 0, 0 0 b count_b, count_c = 0, 0, 0 0 count_b count_c = 0, 0, 0 0 count_c ans = float("inf") float("inf") ans use_list = list(product(range(4), repeat=n)) list(product(range(4), repeat=n)) use_list cost = 0 0 cost count_a += 1 1 count_a count_c += 1 1 count_c
from itertools import product
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]
# 3:A 2:B 1:C 0:使わない
ans = float("inf")
use_list = list(product(range(4), repeat=n))
#print(use_list)
for take_use in use_list:
    a, b, c = 0, 0, 0
    count_a, count_b, count_c = 0, 0, 0
    cost = 0
    for j in range(n):
        if take_use[j] == 3:
            a += l[j]
            count_a += 1
        elif take_use[j] == 2:
            b += l[j]
            count_b += 1
        elif take_use[j] == 1:
            c += l[j]
            count_c += 1
    if count_a == 0 or count_b == 0 or count_c == 0:
        continue
    cost += (count_a-1 + count_b-1 + count_c-1)*10
    cost += abs(A-a) + abs(B-b) + abs(C-c)
    ans = min(ans, cost)
print(ans)
