import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long A, long B, long C, long[] l) {
    long dfs(long[] forA, long[] forB, long[] forC, long[] bamboos) {
        if (bamboos.length > 0)
            return min(
                dfs(forA, forB, forC, bamboos[1 .. $]),
                dfs(forA ~ bamboos[0], forB, forC, bamboos[1 .. $]),
                dfs(forA, forB ~ bamboos[0], forC, bamboos[1 .. $]),
                dfs(forA, forB, forC ~ bamboos[0], bamboos[1 .. $]));
        
        if (forA.length <= 0 || forB.length <= 0 || forC.length <= 0)
            return long.max;

        return
            abs(forA.sum - A) + (forA.length - 1) * 10 +
            abs(forB.sum - B) + (forB.length - 1) * 10 +
            abs(forC.sum - C) + (forC.length - 1) * 10;
    }

    return dfs([], [], [], l);
}

void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long A;
    A = input.front.to!long;
    input.popFront;

    long B;
    B = input.front.to!long;
    input.popFront;

    long C;
    C = input.front.to!long;
    input.popFront;

    long[] l = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        l[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, A, B, C, l);
    else
        solve(N, A, B, C, l).writeln;
}
