#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int N;
int L[8];
int A, B, C;

int dfs(int i, int a, int b, int c) {
	if(i == N) {
		if(!a || !b || !c) return 1e9;
		return abs(a - A) + abs(b - B) + abs(c - C);
	}
	
	int val = 1e9;
	val = min(val, dfs(i+1, a + L[i], b, c) + (a?10:0));
	val = min(val, dfs(i+1, a, b + L[i], c) + (b?10:0));
	val = min(val, dfs(i+1, a, b, c + L[i]) + (c?10:0));
	val = min(val, dfs(i+1, a, b, c));
	
	return val;
}

int main() {
	cin >> N >> A >> B >> C;
	
	for(int i = 0; i < N; i++) cin >> L[i];
	int val = dfs(0, 0, 0, 0);
	cout << val;
	
	return 0;
}