import copy
import collections

def main():
    N,A,B,C=map(int, input().split())
    l = []
    for i in range(N):
        l.append(int(input()))
    l.sort()

    inf = 1 << 60
    best_sc = inf
    q = collections.deque()
    s = (0, l)
    q.append(s)
    try:
        while True:
            s = q.popleft()
            #print(best_sc, s)
            l = s[1]
            if (A in l) and (B in l) and (C in l):
                if best_sc > s[0]:
                    best_sc = s[0]
            if best_sc <= s[0]:
                continue
            if A not in l:
                for i in range(len(l)):
                    l2 = copy.copy(l)
                    l2[i] = A
                    s2 = s[0] + abs(A-l[i])
                    if best_sc > s2:
                        q.append((s2, l2))
            if B not in l:
                for i in range(len(l)):
                    l2 = copy.copy(l)
                    l2[i] = B
                    s2 = s[0] + abs(B-l[i])
                    if best_sc > s2:
                        q.append((s2, l2))
            if C not in l:
                for i in range(len(l)):
                    l2 = copy.copy(l)
                    l2[i] = C
                    s2 = s[0] + abs(C-l[i])
                    if best_sc > s2:
                        q.append((s2, l2))
            if len(l) >= 4:
                for i in range(len(l)-1):
                    for j in range(i+1,len(l)):
                        if l[i]+l[j] > A:
                            continue
                        l2 = copy.copy(l)
                        l2[i] = l[i]+l[j]
                        l2.remove(l[j])
                        s2 = s[0] + 10
                        if best_sc > s2:
                            q.append((s2, l2))
    except IndexError:
        pass
    return best_sc

ans = main()
print(ans)
