import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(1000000000)

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

L = [0] * N
l = []
for _ in range(N):
    L[_] = int(input())
for _ in range(4):
    l.append(_)

X = []
ans = float('inf')


def clear(X):
    global ans
    if len(X) == N:
        Z = [0]*4
        Znum = [0]*4
        for num, i in enumerate(X):
            Znum[i] += 1
            Z[i] += L[num]
        if 0 in Znum[1:]:
            return True
        ansi = abs(A - Z[1]) + abs(B - Z[2]) + abs(C - Z[3]) + (N - Znum[0] - 3) * 10
        ans = min(ans, ansi)
        return True
    else:
        for j in range(4):
            X.append(l[j])
            clear(X)
            X.pop()


clear(X)
print(ans) import sys sys input = sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline sys.setrecursionlimit(1000000000) sys.setrecursionlimit sys setrecursionlimit 1000000000 N, A, B, C = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split A B C L = [0] * N L [0] * N [0] 0 N l = [] l [] for _ in range(N):
    L[_] = int(input()) _ range(N) range N L[_] = int(input()) L[_] L _ int(input()) int input() input for _ in range(4):
    l.append(_) _ range(4) range 4 l.append(_) l.append l append _ X = [] X [] ans = float('inf') ans float('inf') float 'inf' def clear(X):
    global ans
    if len(X) == N:
        Z = [0]*4
        Znum = [0]*4
        for num, i in enumerate(X):
            Znum[i] += 1
            Z[i] += L[num]
        if 0 in Znum[1:]:
            return True
        ansi = abs(A - Z[1]) + abs(B - Z[2]) + abs(C - Z[3]) + (N - Znum[0] - 3) * 10
        ans = min(ans, ansi)
        return True
    else:
        for j in range(4):
            X.append(l[j])
            clear(X)
            X.pop() clear global ans if len(X) == N:
        Z = [0]*4
        Znum = [0]*4
        for num, i in enumerate(X):
            Znum[i] += 1
            Z[i] += L[num]
        if 0 in Znum[1:]:
            return True
        ansi = abs(A - Z[1]) + abs(B - Z[2]) + abs(C - Z[3]) + (N - Znum[0] - 3) * 10
        ans = min(ans, ansi)
        return True
    else:
        for j in range(4):
            X.append(l[j])
            clear(X)
            X.pop() len(X) == N len(X) len X N Z = [0]*4 Z [0]*4 [0] 0 4 Znum = [0]*4 Znum [0]*4 [0] 0 4 for num, i in enumerate(X):
            Znum[i] += 1
            Z[i] += L[num]
         num i enumerate(X) enumerate X Znum[i] += 1 Znum[i] Znum i 1 Z[i] += L[num] Z[i] Z i L[num] L num if 0 in Znum[1:]:
            return True
         0 in Znum[1:] 0 Znum[1:] Znum 1: 1 return True True ansi = abs(A - Z[1]) + abs(B - Z[2]) + abs(C - Z[3]) + (N - Znum[0] - 3) * 10 ansi abs(A - Z[1]) + abs(B - Z[2]) + abs(C - Z[3]) + (N - Znum[0] - 3) * 10 abs(A - Z[1]) + abs(B - Z[2]) + abs(C - Z[3]) abs(A - Z[1]) + abs(B - Z[2]) abs(A - Z[1]) abs A - Z[1] A Z[1] Z 1 abs(B - Z[2]) abs B - Z[2] B Z[2] Z 2 abs(C - Z[3]) abs C - Z[3] C Z[3] Z 3 (N - Znum[0] - 3) * 10 N - Znum[0] - 3 N - Znum[0] N Znum[0] Znum 0 3 10 ans = min(ans, ansi) ans min(ans, ansi) min ans ansi return True True for j in range(4):
            X.append(l[j])
            clear(X)
            X.pop() j range(4) range 4 X.append(l[j]) X.append X append l[j] l j clear(X) clear X X.pop() X.pop X pop X X clear(X) clear X print(ans) print ans ans = float('inf') float('inf') ans N, A, B, C = map(int, input().split()) map(int, input().split()) N C = map(int, input().split()) map(int, input().split()) C A, B, C = map(int, input().split()) map(int, input().split()) A def clear(X):
    global ans
    if len(X) == N:
        Z = [0]*4
        Znum = [0]*4
        for num, i in enumerate(X):
            Znum[i] += 1
            Z[i] += L[num]
        if 0 in Znum[1:]:
            return True
        ansi = abs(A - Z[1]) + abs(B - Z[2]) + abs(C - Z[3]) + (N - Znum[0] - 3) * 10
        ans = min(ans, ansi)
        return True
    else:
        for j in range(4):
            X.append(l[j])
            clear(X)
            X.pop() def clear(X):
    global ans
    if len(X) == N:
        Z = [0]*4
        Znum = [0]*4
        for num, i in enumerate(X):
            Znum[i] += 1
            Z[i] += L[num]
        if 0 in Znum[1:]:
            return True
        ansi = abs(A - Z[1]) + abs(B - Z[2]) + abs(C - Z[3]) + (N - Znum[0] - 3) * 10
        ans = min(ans, ansi)
        return True
    else:
        for j in range(4):
            X.append(l[j])
            clear(X)
            X.pop() clear B, C = map(int, input().split()) map(int, input().split()) B L = [0] * N [0] * N L l = [] [] l input = sys.stdin.buffer.readline sys.stdin.buffer.readline input X = [] [] X
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(1000000000)

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

L = [0] * N
l = []
for _ in range(N):
    L[_] = int(input())
for _ in range(4):
    l.append(_)

X = []
ans = float('inf')


def clear(X):
    global ans
    if len(X) == N:
        Z = [0]*4
        Znum = [0]*4
        for num, i in enumerate(X):
            Znum[i] += 1
            Z[i] += L[num]
        if 0 in Znum[1:]:
            return True
        ansi = abs(A - Z[1]) + abs(B - Z[2]) + abs(C - Z[3]) + (N - Znum[0] - 3) * 10
        ans = min(ans, ansi)
        return True
    else:
        for j in range(4):
            X.append(l[j])
            clear(X)
            X.pop()


clear(X)
print(ans)
