N, A, B, C = map(int, input().split())
T = []
for i in range(N):
    T.append(int(input()))

ans = float("inf")
def loop(K):
    global ans
    abs_A = []
    abs_B = []
    abs_C = []
    for i in range(len(K)):
        abs_A.append(abs(A - K[i]))
        abs_B.append(abs(B - K[i]))
        abs_C.append(abs(C - K[i]))
    for i in range(len(K)):
        for j in range(len(K)):
            for k in range(len(K)):
                if i != j and j != k and k != i:
                    ans = min(ans, 10*(N-len(K)) + abs_A[i] + abs_B[j] + abs_C[k])
    if len(K) > 3:
        Next = []
        for i in range(len(K)):
            for j in range(i+1, len(K)):
                for p in range(len(K)):
                    if p != i and p != j:
                        Next.append(K[p])
                Next.append(K[i] + K[j])
                loop(Next)
                Next = []

loop(T)
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 T = [] T [] for i in range(N):
    T.append(int(input())) i range(N) range N T.append(int(input())) T.append T append int(input()) int input() input ans = float("inf") ans float("inf") float "inf" def loop(K):
    global ans
    abs_A = []
    abs_B = []
    abs_C = []
    for i in range(len(K)):
        abs_A.append(abs(A - K[i]))
        abs_B.append(abs(B - K[i]))
        abs_C.append(abs(C - K[i]))
    for i in range(len(K)):
        for j in range(len(K)):
            for k in range(len(K)):
                if i != j and j != k and k != i:
                    ans = min(ans, 10*(N-len(K)) + abs_A[i] + abs_B[j] + abs_C[k])
    if len(K) > 3:
        Next = []
        for i in range(len(K)):
            for j in range(i+1, len(K)):
                for p in range(len(K)):
                    if p != i and p != j:
                        Next.append(K[p])
                Next.append(K[i] + K[j])
                loop(Next)
                Next = [] loop global ans abs_A = [] abs_A [] abs_B = [] abs_B [] abs_C = [] abs_C [] for i in range(len(K)):
        abs_A.append(abs(A - K[i]))
        abs_B.append(abs(B - K[i]))
        abs_C.append(abs(C - K[i]))
     i range(len(K)) range len(K) len K abs_A.append(abs(A - K[i])) abs_A.append abs_A append abs(A - K[i]) abs A - K[i] A K[i] K i abs_B.append(abs(B - K[i])) abs_B.append abs_B append abs(B - K[i]) abs B - K[i] B K[i] K i abs_C.append(abs(C - K[i])) abs_C.append abs_C append abs(C - K[i]) abs C - K[i] C K[i] K i for i in range(len(K)):
        for j in range(len(K)):
            for k in range(len(K)):
                if i != j and j != k and k != i:
                    ans = min(ans, 10*(N-len(K)) + abs_A[i] + abs_B[j] + abs_C[k])
     i range(len(K)) range len(K) len K for j in range(len(K)):
            for k in range(len(K)):
                if i != j and j != k and k != i:
                    ans = min(ans, 10*(N-len(K)) + abs_A[i] + abs_B[j] + abs_C[k])
     j range(len(K)) range len(K) len K for k in range(len(K)):
                if i != j and j != k and k != i:
                    ans = min(ans, 10*(N-len(K)) + abs_A[i] + abs_B[j] + abs_C[k])
     k range(len(K)) range len(K) len K if i != j and j != k and k != i:
                    ans = min(ans, 10*(N-len(K)) + abs_A[i] + abs_B[j] + abs_C[k])
     i != j and j != k and k != i i != j and j != k i != j i j j != k j k k != i k i ans = min(ans, 10*(N-len(K)) + abs_A[i] + abs_B[j] + abs_C[k]) ans min(ans, 10*(N-len(K)) + abs_A[i] + abs_B[j] + abs_C[k]) min ans 10*(N-len(K)) + abs_A[i] + abs_B[j] + abs_C[k] 10*(N-len(K)) + abs_A[i] + abs_B[j] 10*(N-len(K)) + abs_A[i] 10*(N-len(K)) 10 N-len(K) N len(K) len K abs_A[i] abs_A i abs_B[j] abs_B j abs_C[k] abs_C k if len(K) > 3:
        Next = []
        for i in range(len(K)):
            for j in range(i+1, len(K)):
                for p in range(len(K)):
                    if p != i and p != j:
                        Next.append(K[p])
                Next.append(K[i] + K[j])
                loop(Next)
                Next = [] len(K) > 3 len(K) len K 3 Next = [] Next [] for i in range(len(K)):
            for j in range(i+1, len(K)):
                for p in range(len(K)):
                    if p != i and p != j:
                        Next.append(K[p])
                Next.append(K[i] + K[j])
                loop(Next)
                Next = [] i range(len(K)) range len(K) len K for j in range(i+1, len(K)):
                for p in range(len(K)):
                    if p != i and p != j:
                        Next.append(K[p])
                Next.append(K[i] + K[j])
                loop(Next)
                Next = [] j range(i+1, len(K)) range i+1 i 1 len(K) len K for p in range(len(K)):
                    if p != i and p != j:
                        Next.append(K[p])
                 p range(len(K)) range len(K) len K if p != i and p != j:
                        Next.append(K[p])
                 p != i and p != j p != i p i p != j p j Next.append(K[p]) Next.append Next append K[p] K p Next.append(K[i] + K[j]) Next.append Next append K[i] + K[j] K[i] K i K[j] K j loop(Next) loop Next Next = [] Next [] K K loop(T) loop T print(ans) print ans A, B, C = map(int, input().split()) map(int, input().split()) A C = map(int, input().split()) map(int, input().split()) C N, A, B, C = map(int, input().split()) map(int, input().split()) N T = [] [] T B, C = map(int, input().split()) map(int, input().split()) B ans = float("inf") float("inf") ans def loop(K):
    global ans
    abs_A = []
    abs_B = []
    abs_C = []
    for i in range(len(K)):
        abs_A.append(abs(A - K[i]))
        abs_B.append(abs(B - K[i]))
        abs_C.append(abs(C - K[i]))
    for i in range(len(K)):
        for j in range(len(K)):
            for k in range(len(K)):
                if i != j and j != k and k != i:
                    ans = min(ans, 10*(N-len(K)) + abs_A[i] + abs_B[j] + abs_C[k])
    if len(K) > 3:
        Next = []
        for i in range(len(K)):
            for j in range(i+1, len(K)):
                for p in range(len(K)):
                    if p != i and p != j:
                        Next.append(K[p])
                Next.append(K[i] + K[j])
                loop(Next)
                Next = [] def loop(K):
    global ans
    abs_A = []
    abs_B = []
    abs_C = []
    for i in range(len(K)):
        abs_A.append(abs(A - K[i]))
        abs_B.append(abs(B - K[i]))
        abs_C.append(abs(C - K[i]))
    for i in range(len(K)):
        for j in range(len(K)):
            for k in range(len(K)):
                if i != j and j != k and k != i:
                    ans = min(ans, 10*(N-len(K)) + abs_A[i] + abs_B[j] + abs_C[k])
    if len(K) > 3:
        Next = []
        for i in range(len(K)):
            for j in range(i+1, len(K)):
                for p in range(len(K)):
                    if p != i and p != j:
                        Next.append(K[p])
                Next.append(K[i] + K[j])
                loop(Next)
                Next = [] loop
N, A, B, C = map(int, input().split())
T = []
for i in range(N):
    T.append(int(input()))

ans = float("inf")
def loop(K):
    global ans
    abs_A = []
    abs_B = []
    abs_C = []
    for i in range(len(K)):
        abs_A.append(abs(A - K[i]))
        abs_B.append(abs(B - K[i]))
        abs_C.append(abs(C - K[i]))
    for i in range(len(K)):
        for j in range(len(K)):
            for k in range(len(K)):
                if i != j and j != k and k != i:
                    ans = min(ans, 10*(N-len(K)) + abs_A[i] + abs_B[j] + abs_C[k])
    if len(K) > 3:
        Next = []
        for i in range(len(K)):
            for j in range(i+1, len(K)):
                for p in range(len(K)):
                    if p != i and p != j:
                        Next.append(K[p])
                Next.append(K[i] + K[j])
                loop(Next)
                Next = []

loop(T)
print(ans)