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;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias SugarWater = Tuple!(long, "swater", long, "sugar");

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 main()
{
    long n, a, b, c;
    scan(n, a, b, c);
    auto takematsu = only(n, a, b, c);
    auto l = new long[](n);
    foreach (ref e; l)
        e = lread();
    long mincost = INF;
    foreach (i; 0 .. (1 << n * 2))
    {
        auto len = new long[](4);
        auto cost = new long[](4);
        auto fbits = i.fourbitary(n);
        foreach (j, e; fbits)
        {
            len[e] += l[j];
            cost[e] += 10;
        }
        if (!(len[1] * len[2] * len[3]))
            continue;

        cost[] -= 10;
        foreach(j; iota(len.length))
            cost[j] += abs(len[j] - takematsu[j]);

        mincost = min(cost.sum - cost[0], mincost);
    }
    mincost.writeln();
}

auto fourbitary(long n, long disit)
{
    auto fbits = new long[](disit);
    long tmp;
    while (n > 0)
    {
        fbits[tmp++] = n % 4;
        n = n >> 2;
    }
    return fbits;
}