#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int N, A, B, C, l[10];

int main(void) {

	cin >> N >> A >> B >> C;

	long long int ans = 999999999999;

	for (int i = 1; i <= N; i++) {
		cin >> l[i];
	}
	vector<int> a, b, c;
	for (int i = 1; i <= pow(4, N); i++) {
		int tmp = i;
		int count = 1;
		a.clear(); b.clear(); c.clear();
		while (tmp > 0) {
			if ((tmp % 4) == 1) { a.push_back(count); }
			else if ((tmp % 4) == 2) { b.push_back(count); }
			else if((tmp%4)==3){ c.push_back(count); }
			count++;
			tmp /= 4;
		}

		if ((a.size() == 0) || (b.size() == 0) || (c.size() == 0)) { continue; }

		long long int tmp_A = 0, tmp_B = 0, tmp_C = 0;
		for (int k = 0; k < (int)a.size(); k++) { tmp_A += l[a[k]]; }
		for (int k = 0; k < (int)b.size(); k++) { tmp_B += l[b[k]]; }
		for (int k = 0; k < (int)c.size(); k++) { tmp_C += l[c[k]]; }

		long long int MP = 0;
		MP += (a.size() - 1) * 10 + (b.size() - 1) * 10 + (c.size() - 1) * 10;

		/*cout << "a "; for (int k = 0; k < (int)a.size(); k++) { cout << a[k] << " "; } cout << endl;
		cout << "b "; for (int k = 0; k < (int)b.size(); k++) { cout << b[k] << " "; } cout << endl;
		cout << "c "; for (int k = 0; k < (int)c.size(); k++) { cout << c[k] << " "; } cout << endl;
		//cout << "tmp_A= " << tmp_A << " tmp_B= " << tmp_B << "tmp_C= " << tmp_C << endl;
		*/
		MP += abs(A - tmp_A);
		MP += abs(B - tmp_B);
		MP += abs(C - tmp_C);

		ans = min(ans, MP);

	}

	cout << ans << endl;

	//system("pause");
	return 0;
}