from itertools import product
def solve():
    N,A,B,C = map(int,input().split())
    models = [A,B,C]
    l = [int(input()) for _ in range(N)]

    comb = list(product([-1,0,1,2],repeat=N))

    mn = float('inf')
    for c in comb:
        sm = 0
        for i in range(3):
            elements = []
            for j in range(N):
                if c[j] == i:
                    elements.append(l[j])
            
            if len(elements) == 0:
                break
            sm += (len(elements) - 1) * 10
            sm += abs(models[i] - sum(elements))
        else:
            mn = min(mn, sm)
    
    print(mn)

if __name__ == '__main__':
    solve() from itertools import product def solve():
    N,A,B,C = map(int,input().split())
    models = [A,B,C]
    l = [int(input()) for _ in range(N)]

    comb = list(product([-1,0,1,2],repeat=N))

    mn = float('inf')
    for c in comb:
        sm = 0
        for i in range(3):
            elements = []
            for j in range(N):
                if c[j] == i:
                    elements.append(l[j])
            
            if len(elements) == 0:
                break
            sm += (len(elements) - 1) * 10
            sm += abs(models[i] - sum(elements))
        else:
            mn = min(mn, sm)
    
    print(mn) solve N,A,B,C = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split A B C models = [A,B,C] models [A,B,C] 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)] comb = list(product([-1,0,1,2],repeat=N)) comb list(product([-1,0,1,2],repeat=N)) list product([-1,0,1,2],repeat=N) product [-1,0,1,2] -1 0 1 2 repeat=N repeat N mn = float('inf') mn float('inf') float 'inf' for c in comb:
        sm = 0
        for i in range(3):
            elements = []
            for j in range(N):
                if c[j] == i:
                    elements.append(l[j])
            
            if len(elements) == 0:
                break
            sm += (len(elements) - 1) * 10
            sm += abs(models[i] - sum(elements))
        else:
            mn = min(mn, sm)
    
     c comb sm = 0 sm 0 for i in range(3):
            elements = []
            for j in range(N):
                if c[j] == i:
                    elements.append(l[j])
            
            if len(elements) == 0:
                break
            sm += (len(elements) - 1) * 10
            sm += abs(models[i] - sum(elements))
        else:
            mn = min(mn, sm)
    
     i range(3) range 3 elements = [] elements [] for j in range(N):
                if c[j] == i:
                    elements.append(l[j])
            
             j range(N) range N if c[j] == i:
                    elements.append(l[j])
            
             c[j] == i c[j] c j i elements.append(l[j]) elements.append elements append l[j] l j if len(elements) == 0:
                break
             len(elements) == 0 len(elements) len elements 0 break sm += (len(elements) - 1) * 10 sm (len(elements) - 1) * 10 len(elements) - 1 len(elements) len elements 1 10 sm += abs(models[i] - sum(elements)) sm abs(models[i] - sum(elements)) abs models[i] - sum(elements) models[i] models i sum(elements) sum elements mn = min(mn, sm) mn min(mn, sm) min mn sm print(mn) print mn if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve def solve():
    N,A,B,C = map(int,input().split())
    models = [A,B,C]
    l = [int(input()) for _ in range(N)]

    comb = list(product([-1,0,1,2],repeat=N))

    mn = float('inf')
    for c in comb:
        sm = 0
        for i in range(3):
            elements = []
            for j in range(N):
                if c[j] == i:
                    elements.append(l[j])
            
            if len(elements) == 0:
                break
            sm += (len(elements) - 1) * 10
            sm += abs(models[i] - sum(elements))
        else:
            mn = min(mn, sm)
    
    print(mn) def solve():
    N,A,B,C = map(int,input().split())
    models = [A,B,C]
    l = [int(input()) for _ in range(N)]

    comb = list(product([-1,0,1,2],repeat=N))

    mn = float('inf')
    for c in comb:
        sm = 0
        for i in range(3):
            elements = []
            for j in range(N):
                if c[j] == i:
                    elements.append(l[j])
            
            if len(elements) == 0:
                break
            sm += (len(elements) - 1) * 10
            sm += abs(models[i] - sum(elements))
        else:
            mn = min(mn, sm)
    
    print(mn) solve
from itertools import product
def solve():
    N,A,B,C = map(int,input().split())
    models = [A,B,C]
    l = [int(input()) for _ in range(N)]

    comb = list(product([-1,0,1,2],repeat=N))

    mn = float('inf')
    for c in comb:
        sm = 0
        for i in range(3):
            elements = []
            for j in range(N):
                if c[j] == i:
                    elements.append(l[j])
            
            if len(elements) == 0:
                break
            sm += (len(elements) - 1) * 10
            sm += abs(models[i] - sum(elements))
        else:
            mn = min(mn, sm)
    
    print(mn)

if __name__ == '__main__':
    solve()