# coding: utf-8
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# N本の竹それぞれA, B, C, 使わないか
N, A, B, C = lr()
bamboo = [ir() for _ in range(N)]
answer = 10 **  5
for pattern in itertools.product(range(4), repeat=N):
    mp = 0
    Alist = []; Blist = []; Clist = []
    for i, p in enumerate(pattern):
        if p == 0:
            Alist.append(bamboo[i])
        elif p == 1:
            Blist.append(bamboo[i])
        elif p == 2:
            Clist.append(bamboo[i])
    if len(Alist) == 0 or len(Blist) == 0 or len(Clist) == 0:
        continue
    mp += 10 * (len(Alist) + len(Blist) + len(Clist) - 3)
    mp += abs(A - sum(Alist)) + abs(B - sum(Blist)) + abs(C - sum(Clist))
    if mp < answer:
        answer = mp

print(answer)
# 04 import sys sys import itertools itertools sr = lambda: sys.stdin.readline().rstrip() sr lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip ir = lambda: int(sr()) ir lambda: int(sr()) int(sr()) int sr() sr lr = lambda: list(map(int, sr().split())) lr lambda: list(map(int, sr().split())) list(map(int, sr().split())) list map(int, sr().split()) map int sr().split() ().split () sr split N, A, B, C = lr() N lr() lr A B C ir() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) ir() ir bamboo = [ir() for _ in range(N)] bamboo [ir() for _ in range(N)] answer = 10 **  5 answer 10 **  5 10 5 for pattern in itertools.product(range(4), repeat=N):
    mp = 0
    Alist = []; Blist = []; Clist = []
    for i, p in enumerate(pattern):
        if p == 0:
            Alist.append(bamboo[i])
        elif p == 1:
            Blist.append(bamboo[i])
        elif p == 2:
            Clist.append(bamboo[i])
    if len(Alist) == 0 or len(Blist) == 0 or len(Clist) == 0:
        continue
    mp += 10 * (len(Alist) + len(Blist) + len(Clist) - 3)
    mp += abs(A - sum(Alist)) + abs(B - sum(Blist)) + abs(C - sum(Clist))
    if mp < answer:
        answer = mp pattern itertools.product(range(4), repeat=N) itertools.product itertools product range(4) range 4 repeat=N repeat N mp = 0 mp 0 Alist = [] Alist [] Blist = [] Blist [] Clist = [] Clist [] for i, p in enumerate(pattern):
        if p == 0:
            Alist.append(bamboo[i])
        elif p == 1:
            Blist.append(bamboo[i])
        elif p == 2:
            Clist.append(bamboo[i])
     i p enumerate(pattern) enumerate pattern if p == 0:
            Alist.append(bamboo[i])
        elif p == 1:
            Blist.append(bamboo[i])
        elif p == 2:
            Clist.append(bamboo[i])
     p == 0 p 0 Alist.append(bamboo[i]) Alist.append Alist append bamboo[i] bamboo i elif p == 1:
            Blist.append(bamboo[i])
         p == 1 p 1 Blist.append(bamboo[i]) Blist.append Blist append bamboo[i] bamboo i elif p == 2:
            Clist.append(bamboo[i])
     p == 2 p 2 Clist.append(bamboo[i]) Clist.append Clist append bamboo[i] bamboo i if len(Alist) == 0 or len(Blist) == 0 or len(Clist) == 0:
        continue
     len(Alist) == 0 or len(Blist) == 0 or len(Clist) == 0 len(Alist) == 0 or len(Blist) == 0 len(Alist) == 0 len(Alist) len Alist 0 len(Blist) == 0 len(Blist) len Blist 0 len(Clist) == 0 len(Clist) len Clist 0 continue mp += 10 * (len(Alist) + len(Blist) + len(Clist) - 3) mp 10 * (len(Alist) + len(Blist) + len(Clist) - 3) 10 len(Alist) + len(Blist) + len(Clist) - 3 len(Alist) + len(Blist) + len(Clist) len(Alist) + len(Blist) len(Alist) len Alist len(Blist) len Blist len(Clist) len Clist 3 mp += abs(A - sum(Alist)) + abs(B - sum(Blist)) + abs(C - sum(Clist)) mp abs(A - sum(Alist)) + abs(B - sum(Blist)) + abs(C - sum(Clist)) abs(A - sum(Alist)) + abs(B - sum(Blist)) abs(A - sum(Alist)) abs A - sum(Alist) A sum(Alist) sum Alist abs(B - sum(Blist)) abs B - sum(Blist) B sum(Blist) sum Blist abs(C - sum(Clist)) abs C - sum(Clist) C sum(Clist) sum Clist if mp < answer:
        answer = mp mp < answer mp answer answer = mp answer mp print(answer) print answer A, B, C = lr() lr() A Clist = [] [] Clist answer = mp mp answer N, A, B, C = lr() lr() N Alist = [] [] Alist answer = 10 **  5 10 **  5 answer sr = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() sr lr = lambda: list(map(int, sr().split())) lambda: list(map(int, sr().split())) lr Blist = [] [] Blist bamboo = [ir() for _ in range(N)] [ir() for _ in range(N)] bamboo mp += 10 * (len(Alist) + len(Blist) + len(Clist) - 3) 10 * (len(Alist) + len(Blist) + len(Clist) - 3) mp mp = 0 0 mp mp += abs(A - sum(Alist)) + abs(B - sum(Blist)) + abs(C - sum(Clist)) abs(A - sum(Alist)) + abs(B - sum(Blist)) + abs(C - sum(Clist)) mp ir = lambda: int(sr()) lambda: int(sr()) ir B, C = lr() lr() B C = lr() lr() C
# coding: utf-8
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# N本の竹それぞれA, B, C, 使わないか
N, A, B, C = lr()
bamboo = [ir() for _ in range(N)]
answer = 10 **  5
for pattern in itertools.product(range(4), repeat=N):
    mp = 0
    Alist = []; Blist = []; Clist = []
    for i, p in enumerate(pattern):
        if p == 0:
            Alist.append(bamboo[i])
        elif p == 1:
            Blist.append(bamboo[i])
        elif p == 2:
            Clist.append(bamboo[i])
    if len(Alist) == 0 or len(Blist) == 0 or len(Clist) == 0:
        continue
    mp += 10 * (len(Alist) + len(Blist) + len(Clist) - 3)
    mp += abs(A - sum(Alist)) + abs(B - sum(Blist)) + abs(C - sum(Clist))
    if mp < answer:
        answer = mp

print(answer)
# 04