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

using namespace std;

int main()
{
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<int> l(n);
	for (int i = 0; i < n; i++)cin >> l[i];
	int x = pow(4, n);
	int ret = 1145141919;
	for (int i = 0; i < x; i++)
	{
		int aa = 0, bb = 0, cc = 0, uni = n;
		for (int j = 0; j < n; j++)
		{
			int k = pow(4, j);
			switch (i / k % 4)
			{
			case 1:
				{
					aa += l[j];
					break;
				}
			case 2:
				{
					bb += l[j];
					break;
				}
			case 3:
				{
					cc += l[j];
					break;
				}
			default:
				{
					uni--;
					break;
				}
			}
		}
		if (aa * bb * cc == 0)continue;
		ret = min(ret, abs(a - aa) + abs(b - bb) + abs(c - cc) + (uni - 3) * 10);
	}
	cout << ret << endl;
	return 0;
}
