N, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(N)]
used = [0]*N
global pattern
pattern = []
global ans
ans = float('inf')

def dfs(A):
    global pattern
    global ans
    if len(A) == N:
        pattern.append(A)
        ans = min(ans, MP(A))
        return
    
    for i in range(4):
        A.append(i)
        dfs(A)
        A.pop()

    return 

def MP(A):
    group1 = []
    group2 = []
    group3 = []
    for i in range(N):
        if A[i] == 1:
            group1 += [l[i]]
        elif A[i] == 2:
            group2 += [l[i]]
        elif A[i] == 3:
            group3 += [l[i]]
    if len(group1) == 0 or len(group2) == 0 or len(group3) == 0:
        return float('inf')

    return calc(group1, a)+calc(group2, b)+calc(group3, c)
    
def calc(group, length):
    res = float('inf')
    for i in range(2**len(group)):
        bag = []
        for j in range(len(group)):
            if (i>>j) & 1:
                bag += [group[j]]
        
        if len(bag) == 0:
            continue
        elif len(bag) == 1:
            res = min(res, abs(length - bag[0]))
        else:
            res = min(res, abs(length - sum(group)) + 10*(len(group)-1))
        
    return res

dfs([])
print(ans) 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)] used = [0]*N used [0]*N [0] 0 N global pattern pattern = [] pattern [] global ans ans = float('inf') ans float('inf') float 'inf' def dfs(A):
    global pattern
    global ans
    if len(A) == N:
        pattern.append(A)
        ans = min(ans, MP(A))
        return
    
    for i in range(4):
        A.append(i)
        dfs(A)
        A.pop()

    return  dfs global pattern global ans if len(A) == N:
        pattern.append(A)
        ans = min(ans, MP(A))
        return
    
     len(A) == N len(A) len A N pattern.append(A) pattern.append pattern append A ans = min(ans, MP(A)) ans min(ans, MP(A)) min ans MP(A) MP A return for i in range(4):
        A.append(i)
        dfs(A)
        A.pop()

     i range(4) range 4 A.append(i) A.append A append i dfs(A) dfs A A.pop() A.pop A pop return A A def MP(A):
    group1 = []
    group2 = []
    group3 = []
    for i in range(N):
        if A[i] == 1:
            group1 += [l[i]]
        elif A[i] == 2:
            group2 += [l[i]]
        elif A[i] == 3:
            group3 += [l[i]]
    if len(group1) == 0 or len(group2) == 0 or len(group3) == 0:
        return float('inf')

    return calc(group1, a)+calc(group2, b)+calc(group3, c)
     MP group1 = [] group1 [] group2 = [] group2 [] group3 = [] group3 [] for i in range(N):
        if A[i] == 1:
            group1 += [l[i]]
        elif A[i] == 2:
            group2 += [l[i]]
        elif A[i] == 3:
            group3 += [l[i]]
     i range(N) range N if A[i] == 1:
            group1 += [l[i]]
        elif A[i] == 2:
            group2 += [l[i]]
        elif A[i] == 3:
            group3 += [l[i]]
     A[i] == 1 A[i] A i 1 group1 += [l[i]] group1 [l[i]] l[i] l i elif A[i] == 2:
            group2 += [l[i]]
         A[i] == 2 A[i] A i 2 group2 += [l[i]] group2 [l[i]] l[i] l i elif A[i] == 3:
            group3 += [l[i]]
     A[i] == 3 A[i] A i 3 group3 += [l[i]] group3 [l[i]] l[i] l i if len(group1) == 0 or len(group2) == 0 or len(group3) == 0:
        return float('inf')

     len(group1) == 0 or len(group2) == 0 or len(group3) == 0 len(group1) == 0 or len(group2) == 0 len(group1) == 0 len(group1) len group1 0 len(group2) == 0 len(group2) len group2 0 len(group3) == 0 len(group3) len group3 0 return float('inf') float('inf') float 'inf' return calc(group1, a)+calc(group2, b)+calc(group3, c) calc(group1, a)+calc(group2, b)+calc(group3, c) calc(group1, a)+calc(group2, b) calc(group1, a) calc group1 a calc(group2, b) calc group2 b calc(group3, c) calc group3 c A A def calc(group, length):
    res = float('inf')
    for i in range(2**len(group)):
        bag = []
        for j in range(len(group)):
            if (i>>j) & 1:
                bag += [group[j]]
        
        if len(bag) == 0:
            continue
        elif len(bag) == 1:
            res = min(res, abs(length - bag[0]))
        else:
            res = min(res, abs(length - sum(group)) + 10*(len(group)-1))
        
    return res calc res = float('inf') res float('inf') float 'inf' for i in range(2**len(group)):
        bag = []
        for j in range(len(group)):
            if (i>>j) & 1:
                bag += [group[j]]
        
        if len(bag) == 0:
            continue
        elif len(bag) == 1:
            res = min(res, abs(length - bag[0]))
        else:
            res = min(res, abs(length - sum(group)) + 10*(len(group)-1))
        
     i range(2**len(group)) range 2**len(group) 2 len(group) len group bag = [] bag [] for j in range(len(group)):
            if (i>>j) & 1:
                bag += [group[j]]
        
         j range(len(group)) range len(group) len group if (i>>j) & 1:
                bag += [group[j]]
        
         (i>>j) & 1 i>>j i j 1 bag += [group[j]] bag [group[j]] group[j] group j if len(bag) == 0:
            continue
        elif len(bag) == 1:
            res = min(res, abs(length - bag[0]))
        else:
            res = min(res, abs(length - sum(group)) + 10*(len(group)-1))
        
     len(bag) == 0 len(bag) len bag 0 continue elif len(bag) == 1:
            res = min(res, abs(length - bag[0]))
         len(bag) == 1 len(bag) len bag 1 res = min(res, abs(length - bag[0])) res min(res, abs(length - bag[0])) min res abs(length - bag[0]) abs length - bag[0] length bag[0] bag 0 res = min(res, abs(length - sum(group)) + 10*(len(group)-1)) res min(res, abs(length - sum(group)) + 10*(len(group)-1)) min res abs(length - sum(group)) + 10*(len(group)-1) abs(length - sum(group)) abs length - sum(group) length sum(group) sum group 10*(len(group)-1) 10 len(group)-1 len(group) len group 1 return res res group group length length dfs([]) dfs [] print(ans) print ans c = map(int, input().split()) map(int, input().split()) c global pattern pattern = [] [] pattern l = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] l N, a, b, c = map(int, input().split()) map(int, input().split()) N global ans def calc(group, length):
    res = float('inf')
    for i in range(2**len(group)):
        bag = []
        for j in range(len(group)):
            if (i>>j) & 1:
                bag += [group[j]]
        
        if len(bag) == 0:
            continue
        elif len(bag) == 1:
            res = min(res, abs(length - bag[0]))
        else:
            res = min(res, abs(length - sum(group)) + 10*(len(group)-1))
        
    return res def calc(group, length):
    res = float('inf')
    for i in range(2**len(group)):
        bag = []
        for j in range(len(group)):
            if (i>>j) & 1:
                bag += [group[j]]
        
        if len(bag) == 0:
            continue
        elif len(bag) == 1:
            res = min(res, abs(length - bag[0]))
        else:
            res = min(res, abs(length - sum(group)) + 10*(len(group)-1))
        
    return res calc used = [0]*N [0]*N used ans = float('inf') float('inf') ans def MP(A):
    group1 = []
    group2 = []
    group3 = []
    for i in range(N):
        if A[i] == 1:
            group1 += [l[i]]
        elif A[i] == 2:
            group2 += [l[i]]
        elif A[i] == 3:
            group3 += [l[i]]
    if len(group1) == 0 or len(group2) == 0 or len(group3) == 0:
        return float('inf')

    return calc(group1, a)+calc(group2, b)+calc(group3, c)
     def MP(A):
    group1 = []
    group2 = []
    group3 = []
    for i in range(N):
        if A[i] == 1:
            group1 += [l[i]]
        elif A[i] == 2:
            group2 += [l[i]]
        elif A[i] == 3:
            group3 += [l[i]]
    if len(group1) == 0 or len(group2) == 0 or len(group3) == 0:
        return float('inf')

    return calc(group1, a)+calc(group2, b)+calc(group3, c)
     MP a, b, c = map(int, input().split()) map(int, input().split()) a def dfs(A):
    global pattern
    global ans
    if len(A) == N:
        pattern.append(A)
        ans = min(ans, MP(A))
        return
    
    for i in range(4):
        A.append(i)
        dfs(A)
        A.pop()

    return  def dfs(A):
    global pattern
    global ans
    if len(A) == N:
        pattern.append(A)
        ans = min(ans, MP(A))
        return
    
    for i in range(4):
        A.append(i)
        dfs(A)
        A.pop()

    return  dfs b, c = map(int, input().split()) map(int, input().split()) b
N, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(N)]
used = [0]*N
global pattern
pattern = []
global ans
ans = float('inf')

def dfs(A):
    global pattern
    global ans
    if len(A) == N:
        pattern.append(A)
        ans = min(ans, MP(A))
        return
    
    for i in range(4):
        A.append(i)
        dfs(A)
        A.pop()

    return 

def MP(A):
    group1 = []
    group2 = []
    group3 = []
    for i in range(N):
        if A[i] == 1:
            group1 += [l[i]]
        elif A[i] == 2:
            group2 += [l[i]]
        elif A[i] == 3:
            group3 += [l[i]]
    if len(group1) == 0 or len(group2) == 0 or len(group3) == 0:
        return float('inf')

    return calc(group1, a)+calc(group2, b)+calc(group3, c)
    
def calc(group, length):
    res = float('inf')
    for i in range(2**len(group)):
        bag = []
        for j in range(len(group)):
            if (i>>j) & 1:
                bag += [group[j]]
        
        if len(bag) == 0:
            continue
        elif len(bag) == 1:
            res = min(res, abs(length - bag[0]))
        else:
            res = min(res, abs(length - sum(group)) + 10*(len(group)-1))
        
    return res

dfs([])
print(ans)
