from itertools import permutations

def get_int():
    return int(input())

def get_int_list():
    return list(map(int, input().split()))

while(True):
    try:
        n, a, b, c = get_int_list()
        l = [get_int() for _ in range(n)]
        ans = 1000000000000
        for take in permutations(l, n):
            #print(take)
            take = list(take)
            cnt = 0
            i = 3
            while True:
                if i >= n:
                    break
                if abs(take[2] - a) <= 10:
                    break
                if take[2] > a:
                    break
                if abs(take[2] + take[i] - a) >= abs(take[2] - a):
                    break
                take[2] += take[i]
                i += 1
                cnt += 10
            cnt += abs(take[2] - a)
            #print(take[2])
            
            while True:
                if i >= n:
                    break
                if abs(take[1] - b) <= 10:
                    break
                if take[1] > b:
                    break
                if abs(take[1] + take[i] - b) >= abs(take[1] - b):
                    break
                take[1] += take[i]
                i += 1
                cnt += 10
            cnt += abs(take[1] - b)
            #print(take[1])

            while True:
                if i >= n:
                    break
                if abs(take[0] - c) <= 10:
                    break
                if take[0] > c:
                    break
                if abs(take[0] + take[i] - c) >= abs(take[0] - c):
                    break
                take[0] += take[i]
                i += 1
                cnt += 10
            cnt += abs(take[0] - c)
            #print(take[0])

            ans = min(ans, cnt)
            #if(ans == 253):
            #    print(take[0], take[1], take[2])
        print(ans)
    except EOFError:
        exit()
