#! /usr/bin/python3

# ABC119 c
import sys

def debug(fmt, *args):
    #print(fmt, *args, file=sys.stderr)
    pass

def minabs(t, ls):
    f
    minc = 10000
    minl = None
    for l in ls:
        m = l - t
        if m < minc:
            minc = m
            minl = l
    return minc, t, minl

def f(t, ls):
    for i, li in enumerate(ls):
        for j, lj in enumerate(ls):
            if j >= i:
                continue
            yield abs(li + lj - t), li, lj

def solve(t, ls):
    def k(x):
        return abs(x)
    cs = sorted((l - t for l in ls), key=k)

    if abs(cs[0]) < 10:
        return cs[0], t, [cs[0]+t]
    if cs[0] > 0:
        return cs[0], t, [cs[0]+t]

    minc, li, lj = min(f(t, ls))
    return minc+10, t, [li, lj]


def main(N, A, B, C, ls):
    """
    A:
    B:
    C:
    """
    count = 0
    #debug(A, B, C) 
    #debug(ls) 
    targets = [A, B, C]

    while targets[:]:
        debug("============================")
        debug("targets", targets) 
        debug("objects", ls) 
        debug("count", count)

        # solve 
        minc, mint, minl = sorted(solve(t, ls) for t in targets)[0]
        if minc < 10:
            count += abs(minc)
            targets.remove(mint)
            debug("solve", mint, "cost", minc, minl)
            for l in minl:
                ls.remove(l)
            continue

        if minc > 0:
            count += minc
            targets.remove(mint)
            debug("solve", mint, "cost", minc, minl)
            for l in minl:
                ls.remove(l)
            continue

        count += 10
        debug("combine", minl)
        ls.remove(minl[0])
        ls.remove(minl[1])
        ls.append(minl[0]+minl[1])
        debug("objects", ls) 

    print(count)


if __name__ == "__main__":
    N, A, B, C = [int(x) for x in input().split()]
    ls = [int(input()) for _ in range(N)]
    main(N, A, B, C, ls)
