#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int n, a, b, c;
ll ans = INF;
int kado[8];
vector<vector<int>> use(4);

void solve(int i = 0) {
	if (i == n) {
		if (use[1].size() == 0 || use[2].size() == 0 || use[3].size() == 0) {
			return;
		}
		else {
			int kl[4] = { 0 };
			rep(j, 1, 4) {
				rep(k, 0, use[j].size()) {
					kl[j] += use[j][k];
				}
			}
			int sub = 10*(use[1].size()+use[2].size()+use[3].size()-3)+abs(a - kl[1]) + abs(b - kl[2]) + abs(c - kl[3]);
			ans = min(ans, sub);
		}
	}
	else {
		rep(j, 0, 4) {
			use[j].push_back(kado[i]);
			solve(i + 1);
			use[j].pop_back();
		}
	}

	return;
}

int main() {

	cin >> n >> a >> b >> c;
	rep(i, 0, n) {
		cin >> kado[i];
	}
	
	solve();

	cout << ans << endl;

	return 0;
}
