import random as rng

import itertools as it

import collections as col

import heapq as hq

import sys

import copy as cp

sys.setrecursionlimit(10**9)





def dump_impl(*objects):

    print(*objects, file=sys.stderr)





def dump_dummy(*objects):

    pass





dump = dump_impl if "DEBUG" in sys.argv else dump_dummy



N, A, B, C = map(int, input().split())

l = [int(input()) for i in range(N)]

ans = 10**20

for use in it.product({0, 1, 2, 3}, repeat=N):

    ABC = {0: [], 1: [], 2: [], 3: []}

    for i, u in enumerate(use):

        dump(i, u, use)

        ABC[u].append(l[i])

    if any([len(ABC[u]) == 0 for u in {1, 2, 3}]):

        continue

    ans = min(ans, sum([abs(sum(ABC[i]) - x) + (len(ABC[i]) - 1)

                        * 10 for i, x in zip([1, 2, 3], [A, B, C])]))

print(ans)

n, a, b, c = [int(it) for it in input().split()]

ls = [int(eval(input())) for it in range(n)]

def dfs(cur, tmpA, tmpB, tmpC):

    if cur == n:

        return abs(a - tmpA) + abs(b - tmpB) + abs(c - tmpC) if tmpA > 0 and tmpB > 0 and tmpC else 10**20

    return min(

        dfs(cur + 1, tmpA + ls[cur], tmpB, tmpC) + (10 if tmpA > 0 else 0),

        dfs(cur + 1, tmpA, tmpB + ls[cur], tmpC) + (10 if tmpB > 0 else 0),

        dfs(cur + 1, tmpA, tmpB, tmpC + ls[cur]) + (10 if tmpC > 0 else 0),

        dfs(cur + 1, tmpA, tmpB, tmpC)

    )



print((dfs(0, 0, 0, 0)))

import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp

sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
ans = 10**20
for use in it.product({0, 1, 2, 3}, repeat=N):
    ABC = {0: [], 1: [], 2: [], 3: []}
    for i, u in enumerate(use):
        dump(i, u, use)
        ABC[u].append(l[i])
    if any([len(ABC[u]) == 0 for u in {1, 2, 3}]):
        continue
    ans = min(
        ans,
        sum(
            [
                abs(sum(ABC[i]) - x) + (len(ABC[i]) - 1) * 10
                for i, x in zip([1, 2, 3], [A, B, C])
            ]
        ),
    )
print(ans)

n, a, b, c = [int(it) for it in input().split()]
ls = [int(eval(input())) for it in range(n)]


def dfs(cur, tmpA, tmpB, tmpC):
    if cur == n:
        return (
            abs(a - tmpA) + abs(b - tmpB) + abs(c - tmpC)
            if tmpA > 0 and tmpB > 0 and tmpC
            else 10**20
        )
    return min(
        dfs(cur + 1, tmpA + ls[cur], tmpB, tmpC) + (10 if tmpA > 0 else 0),
        dfs(cur + 1, tmpA, tmpB + ls[cur], tmpC) + (10 if tmpB > 0 else 0),
        dfs(cur + 1, tmpA, tmpB, tmpC + ls[cur]) + (10 if tmpC > 0 else 0),
        dfs(cur + 1, tmpA, tmpB, tmpC),
    )


print((dfs(0, 0, 0, 0)))

-import random as rng -import itertools as it -import collections as col -import heapq as hq -import sys -import copy as cp - -sys.setrecursionlimit(10**9) +n, a, b, c = [int(it) for it in input().split()] +ls = [int(eval(input())) for it in range(n)] -def dump_impl(*objects): -    print(*objects, file=sys.stderr) +def dfs(cur, tmpA, tmpB, tmpC): +    if cur == n: +        return ( +            abs(a - tmpA) + abs(b - tmpB) + abs(c - tmpC) +            if tmpA > 0 and tmpB > 0 and tmpC +            else 10**20 +        ) +    return min( +        dfs(cur + 1, tmpA + ls[cur], tmpB, tmpC) + (10 if tmpA > 0 else 0), +        dfs(cur + 1, tmpA, tmpB + ls[cur], tmpC) + (10 if tmpB > 0 else 0), +        dfs(cur + 1, tmpA, tmpB, tmpC + ls[cur]) + (10 if tmpC > 0 else 0), +        dfs(cur + 1, tmpA, tmpB, tmpC), +    ) -def dump_dummy(*objects): -    pass - - -dump = dump_impl if "DEBUG" in sys.argv else dump_dummy -N, A, B, C = map(int, input().split()) -l = [int(input()) for i in range(N)] -ans = 10**20 -for use in it.product({0, 1, 2, 3}, repeat=N): -    ABC = {0: [], 1: [], 2: [], 3: []} -    for i, u in enumerate(use): -        dump(i, u, use) -        ABC[u].append(l[i]) -    if any([len(ABC[u]) == 0 for u in {1, 2, 3}]): -        continue -    ans = min( -        ans, -        sum( -            [ -                abs(sum(ABC[i]) - x) + (len(ABC[i]) - 1) * 10 -                for i, x in zip([1, 2, 3], [A, B, C]) -            ] -        ), -    ) -print(ans) +print((dfs(0, 0, 0, 0)))