import itertools

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

ans = float('inf')
for Lp in itertools.permutations(L):
    Lac = tuple(itertools.accumulate(([0] + list(Lp))))
    for a in range(1, N - 1):
        for b in range(a + 1, N):
            for c in range(b + 1, N + 1):
                A_MP = 10 * (a - 1) + abs(Lac[a] - Lac[0] - A)
                B_MP = 10 * (b - a - 1) + abs(Lac[b] - Lac[a] - B)
                C_MP = 10 * (c - b - 1) + abs(Lac[c] - Lac[b] - C)
                ans = min(ans, A_MP + B_MP + C_MP)
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 = float('inf') ans float('inf') float 'inf' for Lp in itertools.permutations(L):
    Lac = tuple(itertools.accumulate(([0] + list(Lp))))
    for a in range(1, N - 1):
        for b in range(a + 1, N):
            for c in range(b + 1, N + 1):
                A_MP = 10 * (a - 1) + abs(Lac[a] - Lac[0] - A)
                B_MP = 10 * (b - a - 1) + abs(Lac[b] - Lac[a] - B)
                C_MP = 10 * (c - b - 1) + abs(Lac[c] - Lac[b] - C)
                ans = min(ans, A_MP + B_MP + C_MP) Lp itertools.permutations(L) itertools.permutations itertools permutations L Lac = tuple(itertools.accumulate(([0] + list(Lp)))) Lac tuple(itertools.accumulate(([0] + list(Lp)))) tuple itertools.accumulate(([0] + list(Lp))) itertools.accumulate itertools accumulate [0] + list(Lp) [0] 0 list(Lp) list Lp for a in range(1, N - 1):
        for b in range(a + 1, N):
            for c in range(b + 1, N + 1):
                A_MP = 10 * (a - 1) + abs(Lac[a] - Lac[0] - A)
                B_MP = 10 * (b - a - 1) + abs(Lac[b] - Lac[a] - B)
                C_MP = 10 * (c - b - 1) + abs(Lac[c] - Lac[b] - C)
                ans = min(ans, A_MP + B_MP + C_MP) a range(1, N - 1) range 1 N - 1 N 1 for b in range(a + 1, N):
            for c in range(b + 1, N + 1):
                A_MP = 10 * (a - 1) + abs(Lac[a] - Lac[0] - A)
                B_MP = 10 * (b - a - 1) + abs(Lac[b] - Lac[a] - B)
                C_MP = 10 * (c - b - 1) + abs(Lac[c] - Lac[b] - C)
                ans = min(ans, A_MP + B_MP + C_MP) b range(a + 1, N) range a + 1 a 1 N for c in range(b + 1, N + 1):
                A_MP = 10 * (a - 1) + abs(Lac[a] - Lac[0] - A)
                B_MP = 10 * (b - a - 1) + abs(Lac[b] - Lac[a] - B)
                C_MP = 10 * (c - b - 1) + abs(Lac[c] - Lac[b] - C)
                ans = min(ans, A_MP + B_MP + C_MP) c range(b + 1, N + 1) range b + 1 b 1 N + 1 N 1 A_MP = 10 * (a - 1) + abs(Lac[a] - Lac[0] - A) A_MP 10 * (a - 1) + abs(Lac[a] - Lac[0] - A) 10 * (a - 1) 10 a - 1 a 1 abs(Lac[a] - Lac[0] - A) abs Lac[a] - Lac[0] - A Lac[a] - Lac[0] Lac[a] Lac a Lac[0] Lac 0 A B_MP = 10 * (b - a - 1) + abs(Lac[b] - Lac[a] - B) B_MP 10 * (b - a - 1) + abs(Lac[b] - Lac[a] - B) 10 * (b - a - 1) 10 b - a - 1 b - a b a 1 abs(Lac[b] - Lac[a] - B) abs Lac[b] - Lac[a] - B Lac[b] - Lac[a] Lac[b] Lac b Lac[a] Lac a B C_MP = 10 * (c - b - 1) + abs(Lac[c] - Lac[b] - C) C_MP 10 * (c - b - 1) + abs(Lac[c] - Lac[b] - C) 10 * (c - b - 1) 10 c - b - 1 c - b c b 1 abs(Lac[c] - Lac[b] - C) abs Lac[c] - Lac[b] - C Lac[c] - Lac[b] Lac[c] Lac c Lac[b] Lac b C ans = min(ans, A_MP + B_MP + C_MP) ans min(ans, A_MP + B_MP + C_MP) min ans A_MP + B_MP + C_MP A_MP + B_MP A_MP B_MP C_MP print(ans) print ans Lac = tuple(itertools.accumulate(([0] + list(Lp)))) tuple(itertools.accumulate(([0] + list(Lp)))) Lac ans = float('inf') float('inf') ans N, A, B, C = map(int, input().split()) map(int, input().split()) N B, C = map(int, input().split()) map(int, input().split()) B A, B, C = map(int, input().split()) map(int, input().split()) A C = map(int, input().split()) map(int, input().split()) C B_MP = 10 * (b - a - 1) + abs(Lac[b] - Lac[a] - B) 10 * (b - a - 1) + abs(Lac[b] - Lac[a] - B) B_MP A_MP = 10 * (a - 1) + abs(Lac[a] - Lac[0] - A) 10 * (a - 1) + abs(Lac[a] - Lac[0] - A) A_MP C_MP = 10 * (c - b - 1) + abs(Lac[c] - Lac[b] - C) 10 * (c - b - 1) + abs(Lac[c] - Lac[b] - C) C_MP ans = min(ans, A_MP + B_MP + C_MP) min(ans, A_MP + B_MP + C_MP) ans L = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] L
import itertools

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

ans = float('inf')
for Lp in itertools.permutations(L):
    Lac = tuple(itertools.accumulate(([0] + list(Lp))))
    for a in range(1, N - 1):
        for b in range(a + 1, N):
            for c in range(b + 1, N + 1):
                A_MP = 10 * (a - 1) + abs(Lac[a] - Lac[0] - A)
                B_MP = 10 * (b - a - 1) + abs(Lac[b] - Lac[a] - B)
                C_MP = 10 * (c - b - 1) + abs(Lac[c] - Lac[b] - C)
                ans = min(ans, A_MP + B_MP + C_MP)
print(ans)
