#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int,P> PP;
typedef pair<int,PP> PPP;
struct edge { int to;  int cost; };

int l[8];
vector<int>V[4];
int ans=inf;int n, a, b, c; 
signed dfs(int now) {
	if (n == now) {
		if (V[0].size() && V[1].size() && V[2].size()) {
			int xa = 0, xb = 0, xc = 0;
			rep(i, V[0].size())xa += V[0][i];
			rep(i, V[1].size())xb += V[1][i];
			rep(i, V[2].size())xc += V[2][i];
			ans = min(ans, abs(xa - a) + abs(xb - b) + abs(xc - c) + 10 * (V[0].size() + V[1].size() + V[2].size()-3));
			return 0;
		}
		else return 0;
	}
	rep(i, 4) {
		V[i].push_back(l[now]);
		dfs(now + 1);
		V[i].pop_back();
	}
	return 0;
}

signed main() {
	cin >> n >> a >> b >> c;
	rep(i, n)cin >> l[i];
	dfs(0);
	cout << ans << endl;
}