#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
//ABC119C
using namespace std;
int l[10], n, a, b, c;
int f(int i, int p, int q, int r) {
	if (i == n) {
		if (p*q*r == 0)return -1;
		else return abs(p - a) + abs(q - b) + abs(r - c);
	}
	int r1 = -1, rr;
	rr = f(i + 1, p, q, r);
	if (rr > 0) {
		if (r1 < 0)r1 = rr;
		else r1 = min(r1, rr);
	}
	rr = f(i + 1, p + l[i], q, r); if (!p&&rr >= 0)rr += 10;
	if (rr >= 0) {
		if (r1 < 0)r1 = rr;
		else r1 = min(r1, rr);
	}
	rr = f(i + 1, p, q + l[i], r); if (!q&&rr >= 0)rr += 10;
	if (rr >= 0) {
		if (r1 < 0)r1 = rr;
		else r1 = min(r1, rr);
	}
	rr = f(i + 1, p, q, r + l[i]); if (!r&&rr >= 0)rr += 10;
	if (rr >= 0) {
		if (r1 < 0)r1 = rr;
		else r1 = min(r1, rr);
	}
	return r1;
}
signed main() {
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++)cin >> l[i];
	cout << f(0, 0, 0, 0) << endl;
	cin >> n;
	return 0;
}