#include <bits/stdc++.h>

using namespace std;

int l[9];
int main() {
	int n, a, b, c, r = 1e9;
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++)
		cin >> l[i];
	for (int i = 0; i < 1 << n + n; i++) {
		int x[4] = {}, u[] = { -1,-1,-1,-1 };
		for (int j = 0; j < n; j++)
			x[i >> j + j & 3] += l[j], u[i >> j + j & 3]++;
		if (u[1] < 0 || u[2] < 0 || u[3] < 0)
			continue;
		r = min(r, (u[1] + u[2] + u[3]) * 10 + abs(x[1] - a) + abs(x[2] - b) + abs(x[3] - c));
	}
	cout << r << endl;
	return 0;
}
