import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto tmp = readln.split.to!(long[]);
    const N = tmp[0], A = tmp[1], B = tmp[2], C = tmp[3];
    auto ls = N.iota.map!(_ => readln.chomp.to!long).array.sort!((a,b) => a < b).array;

    long func(long[] ls, long[] a, long[] b, long[] c) {
        if (ls.empty) {
            if (a.empty) return long.max;
            if (b.empty) return long.max;
            if (c.empty) return long.max;

            return 
                  (a.length-1) * 10 + abs(a.sum - A)
                + (b.length-1) * 10 + abs(b.sum - B)
                + (c.length-1) * 10 + abs(c.sum - C);
        }
        return [
            func(ls[1..$], a.dup ~ ls[0], b.dup, c.dup),
            func(ls[1..$], a.dup, b.dup ~ ls[0], c.dup),
            func(ls[1..$], a.dup, b.dup, c.dup ~ ls[0]),
            func(ls[1..$], a.dup, b.dup, c.dup)
        ].reduce!min;
    }
    func(ls, [], [], []).writeln;
}
