def getMP(L,A,B,C):
    n = len(L)
    if n == 3:
        a = abs(L[0]-A) + abs(L[1]-B) + abs(L[2]-C)
        b = abs(L[0]-A) + abs(L[2]-B) + abs(L[1]-C)
        c = abs(L[1]-A) + abs(L[0]-B) + abs(L[2]-C)
        d = abs(L[1]-A) + abs(L[2]-B) + abs(L[0]-C)
        e = abs(L[2]-A) + abs(L[0]-B) + abs(L[1]-C)
        f = abs(L[2]-A) + abs(L[1]-B) + abs(L[0]-C)
        return min(a,b,c,d,e,f)
    else:
        ans = 10**7
        for i in range(n):
            M = L + []
            M.pop(i)
            ans = min(ans, getMP(M,A,B,C))
            for j in range(n-i-1):
                M = L + []
                m = M.pop(i)
                M[j+i] += m
                ans = min(ans, getMP(M,A,B,C)+10)
        return ans
    
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

print(getMP(L,A,B,C))