import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

T RD(T = long)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool INSIDE(T)(T x, T b, T e) { return x >= b && x < e; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct UnionFind
{
	void init(long n) { par = new long[](n); foreach (i; 0..n) par[i] = i; }
	long root(long i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(long i, long j) { return root(i) == root(j); }
	void unite(long i, long j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; }
	long[] par;
}

long[] dijkstra(long from, long to, long[][] edges)
{
	long[] path;
	auto cost = new long[](edges.length); fill(cost, long.max); cost[from] = 0;
	long[][] open = [[from]];
	while (!open.empty)
	{
		auto n = open.front; open.popFront;
		auto p = n[0];
		foreach (i; 0..edges.length)
		{
			if (edges[p][i] == -1) continue;
			auto c = cost[p] + edges[p][i];
			if (c < cost[to] && c < cost[i]) { cost[i] = c; if (i == to) path = i ~ n; else open ~= i ~ n; }
		}
	}
	return cost[to] ~ path;
}

void main()
{
	auto N = RD;
	long[] ABC;
	ABC ~= RD;
	ABC ~= RD;
	ABC ~= RD;
	long[] l;
	foreach (i; 0..N)
		l ~= RD;

	auto memo = new long[](256);
	void comp(long[] arr, long x, ulong path)
	{
		memo[path] = x;
		foreach (i, e; arr)
		{
			auto bit = 1UL << i;
			if (bit & path) continue;
			comp(arr, x + e, path | bit);
		}
	}
	comp(l, 0, 0);

	long[2] f(long[] arr, long x, ulong used)
	{
		long use, cost = long.max;
		foreach (i, e; memo)
		{
			if (i & used || i == 0) continue;
			auto c = abs(x - e) + (popcnt(cast(uint)i) - 1) * 10;
			if (c < cost)
			{
				cost = c;
				use  = i;
			}
			
		}
		return [cost, use];
	}

	long cc(long i, long x)
	{
		return abs(x - memo[i]) + (popcnt(cast(uint)i) - 1) * 10;
	}

	long ans = long.max;
	foreach (i; 1..256)
	{
		foreach (j; 1..256)
		{
			if (i & j) continue;
			foreach (k; 1..256)
			{
				if (i & k || j & k) continue;
				ans = min(ans, cc(i, ABC[0]) + cc(j, ABC[1]) + cc(k, ABC[2]));
				
				/*long cost;
				ulong used;
				auto r1 = f(l, ABC[i], used);
				cost += r1[0];
				used |= cast(ulong)r1[1];
				auto r2 = f(l, ABC[j], used);
				cost += r2[0];
				used |= cast(ulong)r2[1];
				auto r3 = f(l, ABC[k], used);
				cost += r3[0];
				if (cost < ans)
				{
					stderr.writeln(r1[0], " ", r2[0], " ", r3[0]);
					stderr.writefln("%b, %b, %b", r1[1], r2[1], r3[1]);
				}
				ans   = min(ans, cost);*/
			}
		}
	}

	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 256