import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, A, B, C;
    scan(N, A, B, C);
    ubyte mask = cast(ubyte)((1 << N) - 1);
    long[] L = new long[](N);
    foreach (i; 0 .. N)
        scan(L[i]);
    long ans = long.max;
    foreach (ubyte i; 0 .. 255)
        foreach (ubyte j; 0 .. 255)
            foreach (ubyte k; 0 .. 255)
            {
                ubyte a, b, c;
                a = cast(ubyte)(i + 1);
                b = cast(ubyte)(j + 1);
                c = cast(ubyte)(k + 1);
                if ((a & mask) != a || (b & mask) != b || (c & mask) != c)
                    continue;
                if ((a & b) != 0 || (b & c) != 0 || (c & a) != 0)
                    continue;
                long[] len = [0, 0, 0];
                ubyte[] choice = [a, b, c];
                long cost;
                foreach (l; 0 .. 8)
                {
                    ubyte mask2 = cast(ubyte)(1 << l);
                    foreach (m, x; choice)
                        if ((x & mask2) != 0)
                        {
                            cost += (len[m] == 0) ? 0 : 10;
                            len[m] += L[l];
                        }
                }
                cost += abs(len[0] - A);
                cost += abs(len[1] - B);
                cost += abs(len[2] - C);
                // if (cost < ans)
                //     writefln("%d %d %d", a, b, c);
                ans = min(ans, cost);
            }
    writeln(ans);
}
