#include<bits/stdc++.h>
using namespace std;


int mi = 10000000;
int N, A, B, C;
vector<int> l(8);

void dfs(int cur,int a,int b,int c,int co) {
  if (cur == N) {
    if (a==0 || b==0 || c==0) return;
    mi = min(mi, co + abs(A - a) + abs(B - b) + abs(C - c));
	return;
  }
  dfs(cur + 1, a + l[cur], b, c, co + 10);
  dfs(cur + 1, a, b + l[cur], c, co + 10);
  dfs(cur + 1, a, b, c + l[cur], co + 10);
  dfs(cur + 1, a, b, c, co);
}


int main() {
  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; i++) cin >> l[i];

  dfs(0, 0, 0, 0, -30);
  cout << mi << endl;
}
