n, a, b, c = map(int, input().split())
take = []

for i in range(n):
    t = int(input())
    take.append(t)

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

def cal_cost(li, a):
    if li == []:
        return 10**12
    co = 0
    if len(li) == 1:
        co += abs(li[0] - a)
    else:
        co += abs(sum(li) - a)
        co += (len(li) - 1) * 10
    return co

min_cost = 10**12
for i in range(4**n):
    cost = 0
    num = Base_10_to_n(i, 4).zfill(n)
    for_A = []
    for_B = []
    for_C = []
    for j in range(n):
        if num[j] == '1':
            for_A.append(take[j])
        elif num[j] == '2':
            for_B.append(take[j])
        elif num[j] == '3':
            for_C.append(take[j])
    cost += cal_cost(for_A, a)
    cost += cal_cost(for_B, b)
    cost += cal_cost(for_C, c)
    if cost < min_cost:
        min_cost = cost

print(min_cost) n, a, b, c = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split a b c take = [] take [] for i in range(n):
    t = int(input())
    take.append(t) i range(n) range n t = int(input()) t int(input()) int input() input take.append(t) take.append take append t def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out Base_10_to_n X_dumy = X X_dumy X out = '' out '' while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
     X_dumy>0 X_dumy 0 out = str(X_dumy%n)+out out str(X_dumy%n)+out str(X_dumy%n) str X_dumy%n X_dumy n out X_dumy = int(X_dumy/n) X_dumy int(X_dumy/n) int X_dumy/n X_dumy n return out out X X n n def cal_cost(li, a):
    if li == []:
        return 10**12
    co = 0
    if len(li) == 1:
        co += abs(li[0] - a)
    else:
        co += abs(sum(li) - a)
        co += (len(li) - 1) * 10
    return co cal_cost if li == []:
        return 10**12
     li == [] li [] return 10**12 10**12 10 12 co = 0 co 0 if len(li) == 1:
        co += abs(li[0] - a)
    else:
        co += abs(sum(li) - a)
        co += (len(li) - 1) * 10
     len(li) == 1 len(li) len li 1 co += abs(li[0] - a) co abs(li[0] - a) abs li[0] - a li[0] li 0 a co += abs(sum(li) - a) co abs(sum(li) - a) abs sum(li) - a sum(li) sum li a co += (len(li) - 1) * 10 co (len(li) - 1) * 10 len(li) - 1 len(li) len li 1 10 return co co li li a a min_cost = 10**12 min_cost 10**12 10 12 for i in range(4**n):
    cost = 0
    num = Base_10_to_n(i, 4).zfill(n)
    for_A = []
    for_B = []
    for_C = []
    for j in range(n):
        if num[j] == '1':
            for_A.append(take[j])
        elif num[j] == '2':
            for_B.append(take[j])
        elif num[j] == '3':
            for_C.append(take[j])
    cost += cal_cost(for_A, a)
    cost += cal_cost(for_B, b)
    cost += cal_cost(for_C, c)
    if cost < min_cost:
        min_cost = cost i range(4**n) range 4**n 4 n cost = 0 cost 0 num = Base_10_to_n(i, 4).zfill(n) num Base_10_to_n(i, 4).zfill(n) (i, 4).zfill (i, 4) Base_10_to_n i 4 zfill n for_A = [] for_A [] for_B = [] for_B [] for_C = [] for_C [] for j in range(n):
        if num[j] == '1':
            for_A.append(take[j])
        elif num[j] == '2':
            for_B.append(take[j])
        elif num[j] == '3':
            for_C.append(take[j])
     j range(n) range n if num[j] == '1':
            for_A.append(take[j])
        elif num[j] == '2':
            for_B.append(take[j])
        elif num[j] == '3':
            for_C.append(take[j])
     num[j] == '1' num[j] num j '1' for_A.append(take[j]) for_A.append for_A append take[j] take j elif num[j] == '2':
            for_B.append(take[j])
         num[j] == '2' num[j] num j '2' for_B.append(take[j]) for_B.append for_B append take[j] take j elif num[j] == '3':
            for_C.append(take[j])
     num[j] == '3' num[j] num j '3' for_C.append(take[j]) for_C.append for_C append take[j] take j cost += cal_cost(for_A, a) cost cal_cost(for_A, a) cal_cost for_A a cost += cal_cost(for_B, b) cost cal_cost(for_B, b) cal_cost for_B b cost += cal_cost(for_C, c) cost cal_cost(for_C, c) cal_cost for_C c if cost < min_cost:
        min_cost = cost cost < min_cost cost min_cost min_cost = cost min_cost cost print(min_cost) print min_cost min_cost = cost cost min_cost for_A = [] [] for_A num = Base_10_to_n(i, 4).zfill(n) Base_10_to_n(i, 4).zfill(n) num def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out Base_10_to_n take = [] [] take min_cost = 10**12 10**12 min_cost cost = 0 0 cost def cal_cost(li, a):
    if li == []:
        return 10**12
    co = 0
    if len(li) == 1:
        co += abs(li[0] - a)
    else:
        co += abs(sum(li) - a)
        co += (len(li) - 1) * 10
    return co def cal_cost(li, a):
    if li == []:
        return 10**12
    co = 0
    if len(li) == 1:
        co += abs(li[0] - a)
    else:
        co += abs(sum(li) - a)
        co += (len(li) - 1) * 10
    return co cal_cost b, c = map(int, input().split()) map(int, input().split()) b a, b, c = map(int, input().split()) map(int, input().split()) a cost += cal_cost(for_A, a) cal_cost(for_A, a) cost c = map(int, input().split()) map(int, input().split()) c cost += cal_cost(for_C, c) cal_cost(for_C, c) cost n, a, b, c = map(int, input().split()) map(int, input().split()) n cost += cal_cost(for_B, b) cal_cost(for_B, b) cost t = int(input()) int(input()) t for_B = [] [] for_B for_C = [] [] for_C
n, a, b, c = map(int, input().split())
take = []

for i in range(n):
    t = int(input())
    take.append(t)

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

def cal_cost(li, a):
    if li == []:
        return 10**12
    co = 0
    if len(li) == 1:
        co += abs(li[0] - a)
    else:
        co += abs(sum(li) - a)
        co += (len(li) - 1) * 10
    return co

min_cost = 10**12
for i in range(4**n):
    cost = 0
    num = Base_10_to_n(i, 4).zfill(n)
    for_A = []
    for_B = []
    for_C = []
    for j in range(n):
        if num[j] == '1':
            for_A.append(take[j])
        elif num[j] == '2':
            for_B.append(take[j])
        elif num[j] == '3':
            for_C.append(take[j])
    cost += cal_cost(for_A, a)
    cost += cal_cost(for_B, b)
    cost += cal_cost(for_C, c)
    if cost < min_cost:
        min_cost = cost

print(min_cost)
