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

from collections import deque

ans = float('inf')

def dfs(i, abc, cost):
    global ans
    stack = deque([[i, abc, cost]])
    while stack:
        i, abc, cost = stack.pop()
        a, b, c = abc
        if i == n:
            if a * b * c:
                ans = min(ans, abs(A-a) + abs(B-b) + abs(C-c) + cost*10)
            continue
        for e in (0, 1, 2, 3):
            n_cost = cost
            n_abc = abc[:]
            if e < 3:
                if abc[e]:
                    n_cost += 1
                n_abc[e] += l[i]
            stack.append([i + 1, n_abc, n_cost])

dfs(0, [0,0,0], 0)

print(ans) 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)] from collections import deque ans = float('inf') ans float('inf') float 'inf' def dfs(i, abc, cost):
    global ans
    stack = deque([[i, abc, cost]])
    while stack:
        i, abc, cost = stack.pop()
        a, b, c = abc
        if i == n:
            if a * b * c:
                ans = min(ans, abs(A-a) + abs(B-b) + abs(C-c) + cost*10)
            continue
        for e in (0, 1, 2, 3):
            n_cost = cost
            n_abc = abc[:]
            if e < 3:
                if abc[e]:
                    n_cost += 1
                n_abc[e] += l[i]
            stack.append([i + 1, n_abc, n_cost]) dfs global ans stack = deque([[i, abc, cost]]) stack deque([[i, abc, cost]]) deque [[i, abc, cost]] [i, abc, cost] i abc cost while stack:
        i, abc, cost = stack.pop()
        a, b, c = abc
        if i == n:
            if a * b * c:
                ans = min(ans, abs(A-a) + abs(B-b) + abs(C-c) + cost*10)
            continue
        for e in (0, 1, 2, 3):
            n_cost = cost
            n_abc = abc[:]
            if e < 3:
                if abc[e]:
                    n_cost += 1
                n_abc[e] += l[i]
            stack.append([i + 1, n_abc, n_cost]) stack i, abc, cost = stack.pop() i stack.pop() stack.pop stack pop abc cost a, b, c = abc a abc b c if i == n:
            if a * b * c:
                ans = min(ans, abs(A-a) + abs(B-b) + abs(C-c) + cost*10)
            continue
         i == n i n if a * b * c:
                ans = min(ans, abs(A-a) + abs(B-b) + abs(C-c) + cost*10)
             a * b * c a * b a b c ans = min(ans, abs(A-a) + abs(B-b) + abs(C-c) + cost*10) ans min(ans, abs(A-a) + abs(B-b) + abs(C-c) + cost*10) min ans abs(A-a) + abs(B-b) + abs(C-c) + cost*10 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 cost*10 cost 10 continue for e in (0, 1, 2, 3):
            n_cost = cost
            n_abc = abc[:]
            if e < 3:
                if abc[e]:
                    n_cost += 1
                n_abc[e] += l[i]
            stack.append([i + 1, n_abc, n_cost]) e (0, 1, 2, 3) 0 1 2 3 n_cost = cost n_cost cost n_abc = abc[:] n_abc abc[:] abc : if e < 3:
                if abc[e]:
                    n_cost += 1
                n_abc[e] += l[i]
             e < 3 e 3 if abc[e]:
                    n_cost += 1
                 abc[e] abc e n_cost += 1 n_cost 1 n_abc[e] += l[i] n_abc[e] n_abc e l[i] l i stack.append([i + 1, n_abc, n_cost]) stack.append stack append [i + 1, n_abc, n_cost] i + 1 i 1 n_abc n_cost i i abc abc cost cost dfs(0, [0,0,0], 0) dfs 0 [0,0,0] 0 0 0 0 print(ans) print ans 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 def dfs(i, abc, cost):
    global ans
    stack = deque([[i, abc, cost]])
    while stack:
        i, abc, cost = stack.pop()
        a, b, c = abc
        if i == n:
            if a * b * c:
                ans = min(ans, abs(A-a) + abs(B-b) + abs(C-c) + cost*10)
            continue
        for e in (0, 1, 2, 3):
            n_cost = cost
            n_abc = abc[:]
            if e < 3:
                if abc[e]:
                    n_cost += 1
                n_abc[e] += l[i]
            stack.append([i + 1, n_abc, n_cost]) def dfs(i, abc, cost):
    global ans
    stack = deque([[i, abc, cost]])
    while stack:
        i, abc, cost = stack.pop()
        a, b, c = abc
        if i == n:
            if a * b * c:
                ans = min(ans, abs(A-a) + abs(B-b) + abs(C-c) + cost*10)
            continue
        for e in (0, 1, 2, 3):
            n_cost = cost
            n_abc = abc[:]
            if e < 3:
                if abc[e]:
                    n_cost += 1
                n_abc[e] += l[i]
            stack.append([i + 1, n_abc, n_cost]) dfs l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l ans = float('inf') float('inf') ans n, A, B, C = map(int, input().split()) map(int, input().split()) n
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]

from collections import deque

ans = float('inf')

def dfs(i, abc, cost):
    global ans
    stack = deque([[i, abc, cost]])
    while stack:
        i, abc, cost = stack.pop()
        a, b, c = abc
        if i == n:
            if a * b * c:
                ans = min(ans, abs(A-a) + abs(B-b) + abs(C-c) + cost*10)
            continue
        for e in (0, 1, 2, 3):
            n_cost = cost
            n_abc = abc[:]
            if e < 3:
                if abc[e]:
                    n_cost += 1
                n_abc[e] += l[i]
            stack.append([i + 1, n_abc, n_cost])

dfs(0, [0,0,0], 0)

print(ans)