import sys
import collections
sys.setrecursionlimit(10**4)
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
dq = collections.deque([(list(l), 0)])
while a:
    pv = dq[0][0]
    pc = dq[0][1]
    dq.popleft()
    if pc > 1000:
        continue
    for i in pv:
        if i > 1500:
            continue
    if a in pv and b in pv and c in pv:
        print(pc)
        exit(0)
    for i in range(len(pv)):
        nv = list(pv)
        nv[i] += 1;
        if (nv[i] >= 1000): continue
        dq.append((nv, pc + 1))
    for i in range(len(pv)):
        nv = list(pv)
        if (nv[i] == 0): continue
        nv[i] -= 1;
        dq.append((nv, pc + 1))
    if (len(pv) > 3):
        for i in range(len(pv)):
            for j in range(i + 1, len(pv)):
                nv = list(pv)
                nv[i] += nv[j]
                nv.pop(j)
                dq.append((nv, pc + 10))