import sys
from itertools import product
N, A, B, C = map(int, sys.stdin.readline().rstrip().split())
L = [int(sys.stdin.readline().rstrip()) for _ in range(N)]
ans = 10**4

for cmb in product(range(4), repeat=N):
    a_sum = 0
    b_sum = 0
    c_sum = 0
    flag_a = 0
    flag_b = 0
    flag_c = 0
    cnt = 0
    for c, l in zip(cmb, L):
        if c == 0:
            a_sum += l
            if flag_a:
                cnt += 1
            else:
                flag_a = 1
        elif c == 1:
            b_sum += l
            if flag_b:
                cnt += 1
            else:
                flag_b = 1
        elif c == 2:
            c_sum += l
            if flag_c:
                cnt += 1
            else:
                flag_c = 1
    if flag_a == flag_b == flag_c == 1:
        ans = min(ans, 10 * cnt + abs(a_sum - A) + abs(b_sum - B) + abs(c_sum - C))
print(ans) import sys sys from itertools import product N, A, B, C = map(int, sys.stdin.readline().rstrip().split()) N map(int, sys.stdin.readline().rstrip().split()) map int sys.stdin.readline().rstrip().split() sys.stdin.readline().rstrip().split sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip split A B C int(sys.stdin.readline().rstrip()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(sys.stdin.readline().rstrip()) int sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip L = [int(sys.stdin.readline().rstrip()) for _ in range(N)] L [int(sys.stdin.readline().rstrip()) for _ in range(N)] ans = 10**4 ans 10**4 10 4 for cmb in product(range(4), repeat=N):
    a_sum = 0
    b_sum = 0
    c_sum = 0
    flag_a = 0
    flag_b = 0
    flag_c = 0
    cnt = 0
    for c, l in zip(cmb, L):
        if c == 0:
            a_sum += l
            if flag_a:
                cnt += 1
            else:
                flag_a = 1
        elif c == 1:
            b_sum += l
            if flag_b:
                cnt += 1
            else:
                flag_b = 1
        elif c == 2:
            c_sum += l
            if flag_c:
                cnt += 1
            else:
                flag_c = 1
    if flag_a == flag_b == flag_c == 1:
        ans = min(ans, 10 * cnt + abs(a_sum - A) + abs(b_sum - B) + abs(c_sum - C)) cmb product(range(4), repeat=N) product range(4) range 4 repeat=N repeat N a_sum = 0 a_sum 0 b_sum = 0 b_sum 0 c_sum = 0 c_sum 0 flag_a = 0 flag_a 0 flag_b = 0 flag_b 0 flag_c = 0 flag_c 0 cnt = 0 cnt 0 for c, l in zip(cmb, L):
        if c == 0:
            a_sum += l
            if flag_a:
                cnt += 1
            else:
                flag_a = 1
        elif c == 1:
            b_sum += l
            if flag_b:
                cnt += 1
            else:
                flag_b = 1
        elif c == 2:
            c_sum += l
            if flag_c:
                cnt += 1
            else:
                flag_c = 1
     c l zip(cmb, L) zip cmb L if c == 0:
            a_sum += l
            if flag_a:
                cnt += 1
            else:
                flag_a = 1
        elif c == 1:
            b_sum += l
            if flag_b:
                cnt += 1
            else:
                flag_b = 1
        elif c == 2:
            c_sum += l
            if flag_c:
                cnt += 1
            else:
                flag_c = 1
     c == 0 c 0 a_sum += l a_sum l if flag_a:
                cnt += 1
            else:
                flag_a = 1
         flag_a cnt += 1 cnt 1 flag_a = 1 flag_a 1 elif c == 1:
            b_sum += l
            if flag_b:
                cnt += 1
            else:
                flag_b = 1
         c == 1 c 1 b_sum += l b_sum l if flag_b:
                cnt += 1
            else:
                flag_b = 1
         flag_b cnt += 1 cnt 1 flag_b = 1 flag_b 1 elif c == 2:
            c_sum += l
            if flag_c:
                cnt += 1
            else:
                flag_c = 1
     c == 2 c 2 c_sum += l c_sum l if flag_c:
                cnt += 1
            else:
                flag_c = 1
     flag_c cnt += 1 cnt 1 flag_c = 1 flag_c 1 if flag_a == flag_b == flag_c == 1:
        ans = min(ans, 10 * cnt + abs(a_sum - A) + abs(b_sum - B) + abs(c_sum - C)) flag_a == flag_b == flag_c == 1 flag_a == flag_b == flag_c flag_a == flag_b flag_a flag_b flag_c 1 ans = min(ans, 10 * cnt + abs(a_sum - A) + abs(b_sum - B) + abs(c_sum - C)) ans min(ans, 10 * cnt + abs(a_sum - A) + abs(b_sum - B) + abs(c_sum - C)) min ans 10 * cnt + abs(a_sum - A) + abs(b_sum - B) + abs(c_sum - C) 10 * cnt + abs(a_sum - A) + abs(b_sum - B) 10 * cnt + abs(a_sum - A) 10 * cnt 10 cnt abs(a_sum - A) abs a_sum - A a_sum A abs(b_sum - B) abs b_sum - B b_sum B abs(c_sum - C) abs c_sum - C c_sum C print(ans) print ans a_sum = 0 0 a_sum flag_c = 1 1 flag_c flag_b = 1 1 flag_b C = map(int, sys.stdin.readline().rstrip().split()) map(int, sys.stdin.readline().rstrip().split()) C cnt = 0 0 cnt cnt += 1 1 cnt cnt += 1 1 cnt c_sum = 0 0 c_sum ans = 10**4 10**4 ans B, C = map(int, sys.stdin.readline().rstrip().split()) map(int, sys.stdin.readline().rstrip().split()) B flag_b = 0 0 flag_b a_sum += l l a_sum A, B, C = map(int, sys.stdin.readline().rstrip().split()) map(int, sys.stdin.readline().rstrip().split()) A b_sum = 0 0 b_sum N, A, B, C = map(int, sys.stdin.readline().rstrip().split()) map(int, sys.stdin.readline().rstrip().split()) N b_sum += l l b_sum ans = min(ans, 10 * cnt + abs(a_sum - A) + abs(b_sum - B) + abs(c_sum - C)) min(ans, 10 * cnt + abs(a_sum - A) + abs(b_sum - B) + abs(c_sum - C)) ans flag_c = 0 0 flag_c cnt += 1 1 cnt flag_a = 0 0 flag_a flag_a = 1 1 flag_a L = [int(sys.stdin.readline().rstrip()) for _ in range(N)] [int(sys.stdin.readline().rstrip()) for _ in range(N)] L c_sum += l l c_sum
import sys
from itertools import product
N, A, B, C = map(int, sys.stdin.readline().rstrip().split())
L = [int(sys.stdin.readline().rstrip()) for _ in range(N)]
ans = 10**4

for cmb in product(range(4), repeat=N):
    a_sum = 0
    b_sum = 0
    c_sum = 0
    flag_a = 0
    flag_b = 0
    flag_c = 0
    cnt = 0
    for c, l in zip(cmb, L):
        if c == 0:
            a_sum += l
            if flag_a:
                cnt += 1
            else:
                flag_a = 1
        elif c == 1:
            b_sum += l
            if flag_b:
                cnt += 1
            else:
                flag_b = 1
        elif c == 2:
            c_sum += l
            if flag_c:
                cnt += 1
            else:
                flag_c = 1
    if flag_a == flag_b == flag_c == 1:
        ans = min(ans, 10 * cnt + abs(a_sum - A) + abs(b_sum - B) + abs(c_sum - C))
print(ans)