n, a, b, c = map(int, input().split())
bamboos = []
for i in range(n):
    bamboo = int(input())
    bamboos.append(bamboo)

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 calc_score(group, target):
    score = 0
    if len(group) > 1:
        score += 10 * (len(group) - 1)
    length = sum(group)
    score += abs(length - target)
    return score

min_score = 10**12
for i in range(4**n):
    num = Base_10_to_n(i, 4).zfill(n)
    score = 0
    group_A = []
    group_B = []
    group_C = []
    for j in range(n):
        if num[j] == '1':
            group_A.append(bamboos[j])
        elif num[j] == '2':
            group_B.append(bamboos[j])
        elif num[j] == '3':
            group_C.append(bamboos[j])
    if len(group_A) == 0 or len(group_B) == 0 or len(group_C) == 0:
        continue
    else:
        score += calc_score(group_A, a)
        score += calc_score(group_B, b)
        score += calc_score(group_C, c)

    if score < min_score:
        min_score = score

print(min_score) n, a, b, c = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split a b c bamboos = [] bamboos [] for i in range(n):
    bamboo = int(input())
    bamboos.append(bamboo) i range(n) range n bamboo = int(input()) bamboo int(input()) int input() input bamboos.append(bamboo) bamboos.append bamboos append bamboo 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 calc_score(group, target):
    score = 0
    if len(group) > 1:
        score += 10 * (len(group) - 1)
    length = sum(group)
    score += abs(length - target)
    return score calc_score score = 0 score 0 if len(group) > 1:
        score += 10 * (len(group) - 1)
     len(group) > 1 len(group) len group 1 score += 10 * (len(group) - 1) score 10 * (len(group) - 1) 10 len(group) - 1 len(group) len group 1 length = sum(group) length sum(group) sum group score += abs(length - target) score abs(length - target) abs length - target length target return score score group group target target min_score = 10**12 min_score 10**12 10 12 for i in range(4**n):
    num = Base_10_to_n(i, 4).zfill(n)
    score = 0
    group_A = []
    group_B = []
    group_C = []
    for j in range(n):
        if num[j] == '1':
            group_A.append(bamboos[j])
        elif num[j] == '2':
            group_B.append(bamboos[j])
        elif num[j] == '3':
            group_C.append(bamboos[j])
    if len(group_A) == 0 or len(group_B) == 0 or len(group_C) == 0:
        continue
    else:
        score += calc_score(group_A, a)
        score += calc_score(group_B, b)
        score += calc_score(group_C, c)

    if score < min_score:
        min_score = score i range(4**n) range 4**n 4 n 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 score = 0 score 0 group_A = [] group_A [] group_B = [] group_B [] group_C = [] group_C [] for j in range(n):
        if num[j] == '1':
            group_A.append(bamboos[j])
        elif num[j] == '2':
            group_B.append(bamboos[j])
        elif num[j] == '3':
            group_C.append(bamboos[j])
     j range(n) range n if num[j] == '1':
            group_A.append(bamboos[j])
        elif num[j] == '2':
            group_B.append(bamboos[j])
        elif num[j] == '3':
            group_C.append(bamboos[j])
     num[j] == '1' num[j] num j '1' group_A.append(bamboos[j]) group_A.append group_A append bamboos[j] bamboos j elif num[j] == '2':
            group_B.append(bamboos[j])
         num[j] == '2' num[j] num j '2' group_B.append(bamboos[j]) group_B.append group_B append bamboos[j] bamboos j elif num[j] == '3':
            group_C.append(bamboos[j])
     num[j] == '3' num[j] num j '3' group_C.append(bamboos[j]) group_C.append group_C append bamboos[j] bamboos j if len(group_A) == 0 or len(group_B) == 0 or len(group_C) == 0:
        continue
    else:
        score += calc_score(group_A, a)
        score += calc_score(group_B, b)
        score += calc_score(group_C, c)

     len(group_A) == 0 or len(group_B) == 0 or len(group_C) == 0 len(group_A) == 0 or len(group_B) == 0 len(group_A) == 0 len(group_A) len group_A 0 len(group_B) == 0 len(group_B) len group_B 0 len(group_C) == 0 len(group_C) len group_C 0 continue score += calc_score(group_A, a) score calc_score(group_A, a) calc_score group_A a score += calc_score(group_B, b) score calc_score(group_B, b) calc_score group_B b score += calc_score(group_C, c) score calc_score(group_C, c) calc_score group_C c if score < min_score:
        min_score = score score < min_score score min_score min_score = score min_score score print(min_score) print min_score b, c = map(int, input().split()) map(int, input().split()) b score += calc_score(group_B, b) calc_score(group_B, b) score a, b, c = map(int, input().split()) map(int, input().split()) a min_score = score score min_score n, a, b, c = map(int, input().split()) map(int, input().split()) n 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 bamboo = int(input()) int(input()) bamboo num = Base_10_to_n(i, 4).zfill(n) Base_10_to_n(i, 4).zfill(n) num bamboos = [] [] bamboos min_score = 10**12 10**12 min_score score = 0 0 score group_C = [] [] group_C group_A = [] [] group_A score += calc_score(group_A, a) calc_score(group_A, a) score group_B = [] [] group_B def calc_score(group, target):
    score = 0
    if len(group) > 1:
        score += 10 * (len(group) - 1)
    length = sum(group)
    score += abs(length - target)
    return score def calc_score(group, target):
    score = 0
    if len(group) > 1:
        score += 10 * (len(group) - 1)
    length = sum(group)
    score += abs(length - target)
    return score calc_score score += calc_score(group_C, c) calc_score(group_C, c) score c = map(int, input().split()) map(int, input().split()) c
n, a, b, c = map(int, input().split())
bamboos = []
for i in range(n):
    bamboo = int(input())
    bamboos.append(bamboo)

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 calc_score(group, target):
    score = 0
    if len(group) > 1:
        score += 10 * (len(group) - 1)
    length = sum(group)
    score += abs(length - target)
    return score

min_score = 10**12
for i in range(4**n):
    num = Base_10_to_n(i, 4).zfill(n)
    score = 0
    group_A = []
    group_B = []
    group_C = []
    for j in range(n):
        if num[j] == '1':
            group_A.append(bamboos[j])
        elif num[j] == '2':
            group_B.append(bamboos[j])
        elif num[j] == '3':
            group_C.append(bamboos[j])
    if len(group_A) == 0 or len(group_B) == 0 or len(group_C) == 0:
        continue
    else:
        score += calc_score(group_A, a)
        score += calc_score(group_B, b)
        score += calc_score(group_C, c)

    if score < min_score:
        min_score = score

print(min_score)