#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 99999999999999999;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;

int a, b, c, d, k[10];

int dfs(int n, int m, int o, int p) {
	if (n == a) {
		if (min({ m,o,p }) > 0) { return abs(m - b) + abs(o - c) + abs(p - d) - 30; }
		else { return INF; }
	}
	return min({ dfs(n + 1,m,o,p),dfs(n + 1,m + k[n],o,p) + 10,dfs(n + 1,m,o + k[n],p) + 10,dfs(n + 1,m,o,p + k[n]) + 10 });
}

int main() {
	cin >> a >> b >> c >> d;
	for (int i = 0; i < a; ++i) {
		cin >> k[i];
	}
	cout << dfs(0, 0, 0, 0) << endl;
}