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

m = 10 ** 6
for choice in range(1, 4 ** (N + 1)):
    bucket = [[] for _ in range(4)]
    #print(choice)
    for j in range(N):
        temp = (choice // 4 ** j) % 4
        bucket[temp].append(l[j])
        #print(temp)
    #print(bucket)
    if bucket[0] and bucket[1] and bucket[2]:
        pass
    else:
        continue
    cost = 0
    for i in range(4):
        if i <= 2 and bucket[i]:
            if len(bucket[i]) >= 2:
                total = sum(bucket[i])
                cost += 10 * (len(bucket[i]) - 1)
            else:
                total = bucket[i][0]
            cost += abs(total - ABC[i])
    m = min(m, cost)
print(m)

 N, A, B, C = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split A B C ABC = [A, B, C] ABC [A, B, C] A B C l = [] l [] for _ in range(N):
    l.append(int(input())) _ range(N) range N l.append(int(input())) l.append l append int(input()) int input() input m = 10 ** 6 m 10 ** 6 10 6 for choice in range(1, 4 ** (N + 1)):
    bucket = [[] for _ in range(4)]
    #print(choice)
    for j in range(N):
        temp = (choice // 4 ** j) % 4
        bucket[temp].append(l[j])
        #print(temp)
    #print(bucket)
    if bucket[0] and bucket[1] and bucket[2]:
        pass
    else:
        continue
    cost = 0
    for i in range(4):
        if i <= 2 and bucket[i]:
            if len(bucket[i]) >= 2:
                total = sum(bucket[i])
                cost += 10 * (len(bucket[i]) - 1)
            else:
                total = bucket[i][0]
            cost += abs(total - ABC[i])
    m = min(m, cost) choice range(1, 4 ** (N + 1)) range 1 4 ** (N + 1) 4 N + 1 N 1 [] for _ in range(4) for _ in range(4) _ range(4) range 4 for _ in range(4) [] bucket = [[] for _ in range(4)] bucket [[] for _ in range(4)] for j in range(N):
        temp = (choice // 4 ** j) % 4
        bucket[temp].append(l[j])
        #print(temp)
    #print(bucket)
     j range(N) range N temp = (choice // 4 ** j) % 4 temp (choice // 4 ** j) % 4 choice // 4 ** j choice 4 ** j 4 j 4 bucket[temp].append(l[j]) [temp].append [temp] bucket temp append l[j] l j if bucket[0] and bucket[1] and bucket[2]:
        pass
    else:
        continue
     bucket[0] and bucket[1] and bucket[2] bucket[0] and bucket[1] bucket[0] bucket 0 bucket[1] bucket 1 bucket[2] bucket 2 continue cost = 0 cost 0 for i in range(4):
        if i <= 2 and bucket[i]:
            if len(bucket[i]) >= 2:
                total = sum(bucket[i])
                cost += 10 * (len(bucket[i]) - 1)
            else:
                total = bucket[i][0]
            cost += abs(total - ABC[i])
     i range(4) range 4 if i <= 2 and bucket[i]:
            if len(bucket[i]) >= 2:
                total = sum(bucket[i])
                cost += 10 * (len(bucket[i]) - 1)
            else:
                total = bucket[i][0]
            cost += abs(total - ABC[i])
     i <= 2 and bucket[i] i <= 2 i 2 bucket[i] bucket i if len(bucket[i]) >= 2:
                total = sum(bucket[i])
                cost += 10 * (len(bucket[i]) - 1)
            else:
                total = bucket[i][0]
             len(bucket[i]) >= 2 len(bucket[i]) len bucket[i] bucket i 2 total = sum(bucket[i]) total sum(bucket[i]) sum bucket[i] bucket i cost += 10 * (len(bucket[i]) - 1) cost 10 * (len(bucket[i]) - 1) 10 len(bucket[i]) - 1 len(bucket[i]) len bucket[i] bucket i 1 total = bucket[i][0] total bucket[i][0] [i] bucket i 0 cost += abs(total - ABC[i]) cost abs(total - ABC[i]) abs total - ABC[i] total ABC[i] ABC i m = min(m, cost) m min(m, cost) min m cost print(m) print m ABC = [A, B, C] [A, B, C] ABC bucket = [[] for _ in range(4)] [[] for _ in range(4)] bucket N, A, B, C = map(int, input().split()) map(int, input().split()) N l = [] [] l A, B, C = map(int, input().split()) map(int, input().split()) A m = 10 ** 6 10 ** 6 m cost = 0 0 cost cost += 10 * (len(bucket[i]) - 1) 10 * (len(bucket[i]) - 1) cost total = bucket[i][0] bucket[i][0] total C = map(int, input().split()) map(int, input().split()) C m = min(m, cost) min(m, cost) m total = sum(bucket[i]) sum(bucket[i]) total cost += abs(total - ABC[i]) abs(total - ABC[i]) cost B, C = map(int, input().split()) map(int, input().split()) B temp = (choice // 4 ** j) % 4 (choice // 4 ** j) % 4 temp
N, A, B, C = map(int, input().split())
ABC = [A, B, C]
l = []
for _ in range(N):
    l.append(int(input()))

m = 10 ** 6
for choice in range(1, 4 ** (N + 1)):
    bucket = [[] for _ in range(4)]
    #print(choice)
    for j in range(N):
        temp = (choice // 4 ** j) % 4
        bucket[temp].append(l[j])
        #print(temp)
    #print(bucket)
    if bucket[0] and bucket[1] and bucket[2]:
        pass
    else:
        continue
    cost = 0
    for i in range(4):
        if i <= 2 and bucket[i]:
            if len(bucket[i]) >= 2:
                total = sum(bucket[i])
                cost += 10 * (len(bucket[i]) - 1)
            else:
                total = bucket[i][0]
            cost += abs(total - ABC[i])
    m = min(m, cost)
print(m)


