#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string>
#include "Source.h"
using namespace std;
typedef pair<int, int>P;

int nearest(int n, vector<int>nums) {
	int ans = 1e9, old_ans;
	int answer;
	for (int i = 0; i < nums.size(); i++) {
		old_ans = ans;
		ans = min(abs(n - nums[i]), ans);
		if (old_ans != ans) {
			answer = nums[i];
		}
	}
	return answer;
}

int main() {
	int n;
	cin >> n;
	int num;
	int a, b, c;
	cin >> a >> b >> c;
	int l[10];
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	int ans = 1e9;
	int mp = 0;
	int number;
	int sum = 0;
	int each_mp=1e9;
	vector<int>ta, tb, tc;
	int cost10 = 0;
	for (int i = 1; i <= pow(3, n); i++) {
		num = i;
		ta = {};
		tb = {};
		tc = {};
		for (int j = 0; j < n; j++) {
			if (num % 3 == 0) {
				ta.push_back(l[j]);
			}
			else if (num % 3 == 1) {
				tb.push_back(l[j]);
			}
			else {
				tc.push_back(l[j]);
			}
			num /= 3;
		}
		//a
		if (ta.size() != 0) {
			sort(ta.begin(), ta.end(), greater<int>());
			if (ta[0] > a) {
				mp += ta[0] - a;
			}
			else {
				for (int j = 1; j < pow(2, ta.size()); j++) {
					number = j;
					for (int k = 0; k < ta.size(); k++) {
						if (k % 2 == 1) {
							sum += ta[k];
							cost10 += 1;
						}
					}
					each_mp = min(each_mp, abs(sum - a) + 10 * cost10);
					sum = 0;
					cost10 = 0;
				}
				mp += each_mp;
			}
		}
		//b
		if (tb.size() != 0) {
			sort(tb.begin(), tb.end(), greater<int>());
			if (tb[0] > b) {
				mp += tb[0] - b;
			}
			else {
				for (int j = 1; j < pow(2, tb.size()); j++) {
					number = j;
					for (int k = 0; k < tb.size(); k++) {
						if (k % 2 == 1) {
							sum += tb[k];
							cost10 += 1;
						}
					}
					each_mp = min(each_mp, abs(sum - b) + 10 * cost10);
					sum = 0;
					cost10 = 0;
				}
				mp += each_mp;
			}
		}
		//c
		if (tc.size() != 0) {
			sort(tc.begin(), tc.end(), greater<int>());
			if (tc[0] > c) {
				mp += tc[0] - c;
			}
			else {
				for (int j = 1; j < pow(2, tc.size()); j++) {
					number = j;
					for (int k = 0; k < tc.size(); k++) {
						if (k % 2 == 1) {
							sum += tc[k];
							cost10 += 1;
						}
					}
					each_mp = min(each_mp, abs(sum - c) + 10 * cost10);
					sum = 0;
					cost10 = 0;
				}
				mp += each_mp;
			}
		}
		ans = min(ans, mp);
		mp = 0;
	}
	cout << ans << endl;
	return 0;
}