from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

min_mp = 10**10

for i in range(4**n):
    mp = 0
    li = [0]*4
    count_li = [0]*4
    s = Base_10_to_n(i,4).zfill(n)

    for j,k in enumerate(s):
        li[int(k)] += l[j]
        count_li[int(k)] += 1

    if 0 in li[:-1]:
        continue

    mp += abs(a-li[0])
    mp += abs(b-li[1])
    mp += abs(c-li[2])

    for item in count_li[:3]:
        if item >= 2:
            mp += 10*(item-1)
            
    min_mp = min(min_mp,mp)

print(min_mp) from sys import setrecursionlimit setrecursionlimit(10 ** 7) setrecursionlimit 10 ** 7 10 7 n,a,b,c = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split a b c int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input l = [int(input()) for _ in range(n)] l [int(input()) for _ in range(n)] def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n) Base_10_to_n if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
     int(X/n) int X/n X n return Base_10_to_n(int(X/n), n)+str(X%n) Base_10_to_n(int(X/n), n)+str(X%n) Base_10_to_n(int(X/n), n) Base_10_to_n int(X/n) int X/n X n n str(X%n) str X%n X n return str(X%n) str(X%n) str X%n X n X X n n min_mp = 10**10 min_mp 10**10 10 10 for i in range(4**n):
    mp = 0
    li = [0]*4
    count_li = [0]*4
    s = Base_10_to_n(i,4).zfill(n)

    for j,k in enumerate(s):
        li[int(k)] += l[j]
        count_li[int(k)] += 1

    if 0 in li[:-1]:
        continue

    mp += abs(a-li[0])
    mp += abs(b-li[1])
    mp += abs(c-li[2])

    for item in count_li[:3]:
        if item >= 2:
            mp += 10*(item-1)
            
    min_mp = min(min_mp,mp) i range(4**n) range 4**n 4 n mp = 0 mp 0 li = [0]*4 li [0]*4 [0] 0 4 count_li = [0]*4 count_li [0]*4 [0] 0 4 s = Base_10_to_n(i,4).zfill(n) s Base_10_to_n(i,4).zfill(n) (i,4).zfill (i,4) Base_10_to_n i 4 zfill n for j,k in enumerate(s):
        li[int(k)] += l[j]
        count_li[int(k)] += 1

     j k enumerate(s) enumerate s li[int(k)] += l[j] li[int(k)] li int(k) int k l[j] l j count_li[int(k)] += 1 count_li[int(k)] count_li int(k) int k 1 if 0 in li[:-1]:
        continue

     0 in li[:-1] 0 li[:-1] li :-1 -1 continue mp += abs(a-li[0]) mp abs(a-li[0]) abs a-li[0] a li[0] li 0 mp += abs(b-li[1]) mp abs(b-li[1]) abs b-li[1] b li[1] li 1 mp += abs(c-li[2]) mp abs(c-li[2]) abs c-li[2] c li[2] li 2 for item in count_li[:3]:
        if item >= 2:
            mp += 10*(item-1)
            
     item count_li[:3] count_li :3 3 if item >= 2:
            mp += 10*(item-1)
            
     item >= 2 item 2 mp += 10*(item-1) mp 10*(item-1) 10 item-1 item 1 min_mp = min(min_mp,mp) min_mp min(min_mp,mp) min min_mp mp print(min_mp) print min_mp a,b,c = map(int,input().split()) map(int,input().split()) a b,c = map(int,input().split()) map(int,input().split()) b mp += abs(c-li[2]) abs(c-li[2]) mp n,a,b,c = map(int,input().split()) map(int,input().split()) n min_mp = 10**10 10**10 min_mp min_mp = min(min_mp,mp) min(min_mp,mp) min_mp c = map(int,input().split()) map(int,input().split()) c mp += abs(a-li[0]) abs(a-li[0]) mp count_li = [0]*4 [0]*4 count_li def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n) def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n) Base_10_to_n s = Base_10_to_n(i,4).zfill(n) Base_10_to_n(i,4).zfill(n) s l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l mp = 0 0 mp mp += abs(b-li[1]) abs(b-li[1]) mp li = [0]*4 [0]*4 li mp += 10*(item-1) 10*(item-1) mp
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

min_mp = 10**10

for i in range(4**n):
    mp = 0
    li = [0]*4
    count_li = [0]*4
    s = Base_10_to_n(i,4).zfill(n)

    for j,k in enumerate(s):
        li[int(k)] += l[j]
        count_li[int(k)] += 1

    if 0 in li[:-1]:
        continue

    mp += abs(a-li[0])
    mp += abs(b-li[1])
    mp += abs(c-li[2])

    for item in count_li[:3]:
        if item >= 2:
            mp += 10*(item-1)
            
    min_mp = min(min_mp,mp)

print(min_mp)