#include<bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
int n, A, B, C, x[10];
int f(int i, int a, int b, int c){
	if(i == n){
		if(!a || !b || !c)
			return inf;
		return abs(A - a) + abs(b - B) + abs(c - C);
	}
	int m1 = f(i + 1, a, b, c);
	m1 = min(m1, f(i + 1, a + x[i], b, c) + (a?10:0));
	m1 = min(m1, f(i + 1, a, b + x[i], c) + (b?10:0));
	m1 = min(m1, f(i + 1, a, b, c + x[i]) + (c?10:0));
	return m1;
}
int main(){
	cin >> n >> A >> B >> C;
	for(int i = 0; i < n; i++)
		cin >> x[i];
	cout << f(0, 0, 0, 0);
}