n, a, b, c = map(int, input().split())
x = [int(input()) for _ in range(n)]

from itertools import permutations

def dfs(idx):
    if idx == n:
        return [[[], [], []]]

    ret = []
    for ll in dfs(idx + 1):
        ret.append(ll)

        for i in range(3):
            ll2 = [ll[0][:], ll[1][:], ll[2][:]]
            ll2[i].append(idx)
            ret.append(ll2)

    return ret

lists = dfs(0)

target = [a, b, c]

ans = float('inf')
for _lists in lists:
    if [] not in _lists:

        point = 0
        l = []
        for lis in _lists:
            l.append(sum([x[i] for i in lis]))
            point += 10 * (len(lis) - 1)

        for perm in permutations(l):
            point2 = point
            for i in range(3):
                point2 += abs(target[i] - perm[i])

            ans = min(point2, ans)

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 x = [int(input()) for _ in range(n)] x [int(input()) for _ in range(n)] from itertools import permutations def dfs(idx):
    if idx == n:
        return [[[], [], []]]

    ret = []
    for ll in dfs(idx + 1):
        ret.append(ll)

        for i in range(3):
            ll2 = [ll[0][:], ll[1][:], ll[2][:]]
            ll2[i].append(idx)
            ret.append(ll2)

    return ret dfs if idx == n:
        return [[[], [], []]]

     idx == n idx n return [[[], [], []]] [[[], [], []]] [[], [], []] [] [] [] ret = [] ret [] for ll in dfs(idx + 1):
        ret.append(ll)

        for i in range(3):
            ll2 = [ll[0][:], ll[1][:], ll[2][:]]
            ll2[i].append(idx)
            ret.append(ll2)

     ll dfs(idx + 1) dfs idx + 1 idx 1 ret.append(ll) ret.append ret append ll for i in range(3):
            ll2 = [ll[0][:], ll[1][:], ll[2][:]]
            ll2[i].append(idx)
            ret.append(ll2)

     i range(3) range 3 ll2 = [ll[0][:], ll[1][:], ll[2][:]] ll2 [ll[0][:], ll[1][:], ll[2][:]] ll[0][:] [0] ll 0 : ll[1][:] [1] ll 1 : ll[2][:] [2] ll 2 : ll2[i].append(idx) [i].append [i] ll2 i append idx ret.append(ll2) ret.append ret append ll2 return ret ret idx idx lists = dfs(0) lists dfs(0) dfs 0 target = [a, b, c] target [a, b, c] a b c ans = float('inf') ans float('inf') float 'inf' for _lists in lists:
    if [] not in _lists:

        point = 0
        l = []
        for lis in _lists:
            l.append(sum([x[i] for i in lis]))
            point += 10 * (len(lis) - 1)

        for perm in permutations(l):
            point2 = point
            for i in range(3):
                point2 += abs(target[i] - perm[i])

            ans = min(point2, ans) _lists lists if [] not in _lists:

        point = 0
        l = []
        for lis in _lists:
            l.append(sum([x[i] for i in lis]))
            point += 10 * (len(lis) - 1)

        for perm in permutations(l):
            point2 = point
            for i in range(3):
                point2 += abs(target[i] - perm[i])

            ans = min(point2, ans) [] not in _lists [] _lists point = 0 point 0 l = [] l [] for lis in _lists:
            l.append(sum([x[i] for i in lis]))
            point += 10 * (len(lis) - 1)

         lis _lists x[i] for i in lis for i in lis i lis for i in lis x[i] x i l.append(sum([x[i] for i in lis])) l.append l append sum([x[i] for i in lis]) sum [x[i] for i in lis] point += 10 * (len(lis) - 1) point 10 * (len(lis) - 1) 10 len(lis) - 1 len(lis) len lis 1 for perm in permutations(l):
            point2 = point
            for i in range(3):
                point2 += abs(target[i] - perm[i])

            ans = min(point2, ans) perm permutations(l) permutations l point2 = point point2 point for i in range(3):
                point2 += abs(target[i] - perm[i])

             i range(3) range 3 point2 += abs(target[i] - perm[i]) point2 abs(target[i] - perm[i]) abs target[i] - perm[i] target[i] target i perm[i] perm i ans = min(point2, ans) ans min(point2, ans) min point2 ans print(ans) print ans l = [] [] l target = [a, b, c] [a, b, c] target def dfs(idx):
    if idx == n:
        return [[[], [], []]]

    ret = []
    for ll in dfs(idx + 1):
        ret.append(ll)

        for i in range(3):
            ll2 = [ll[0][:], ll[1][:], ll[2][:]]
            ll2[i].append(idx)
            ret.append(ll2)

    return ret def dfs(idx):
    if idx == n:
        return [[[], [], []]]

    ret = []
    for ll in dfs(idx + 1):
        ret.append(ll)

        for i in range(3):
            ll2 = [ll[0][:], ll[1][:], ll[2][:]]
            ll2[i].append(idx)
            ret.append(ll2)

    return ret dfs ans = float('inf') float('inf') ans ans = min(point2, ans) min(point2, ans) ans n, a, b, c = map(int, input().split()) map(int, input().split()) n lists = dfs(0) dfs(0) lists point = 0 0 point point += 10 * (len(lis) - 1) 10 * (len(lis) - 1) point c = map(int, input().split()) map(int, input().split()) c point2 = point point point2 point2 += abs(target[i] - perm[i]) abs(target[i] - perm[i]) point2 x = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] x a, b, c = map(int, input().split()) map(int, input().split()) a b, c = map(int, input().split()) map(int, input().split()) b
n, a, b, c = map(int, input().split())
x = [int(input()) for _ in range(n)]

from itertools import permutations

def dfs(idx):
    if idx == n:
        return [[[], [], []]]

    ret = []
    for ll in dfs(idx + 1):
        ret.append(ll)

        for i in range(3):
            ll2 = [ll[0][:], ll[1][:], ll[2][:]]
            ll2[i].append(idx)
            ret.append(ll2)

    return ret

lists = dfs(0)

target = [a, b, c]

ans = float('inf')
for _lists in lists:
    if [] not in _lists:

        point = 0
        l = []
        for lis in _lists:
            l.append(sum([x[i] for i in lis]))
            point += 10 * (len(lis) - 1)

        for perm in permutations(l):
            point2 = point
            for i in range(3):
                point2 += abs(target[i] - perm[i])

            ans = min(point2, ans)

print(ans)
