#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
bool next(vector<int> &use) {
  int n = use.size();
  int p = 1;
  for (int i = 0; i < n; i++) {
    use[i] += p;
    if (use[i] >= 4) {
      use[i] -= 4;
      p = 1;
    } else {
      p = 0;
    }
  }
  return p == 0;
}
int main() {
  int N, A[3], l[1000];
  cin >> N >> A[0] >> A[1] >> A[2];
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }
  int ans = INF;
  vector<int> use(N, 0);
  do {
    int nA[3] = {0, 0, 0};
    int usecount = 0;
    for (int i = 0; i < N; i++) {
      if (use[i] < 3) {
        nA[use[i]] += l[i];
        usecount++;
      }
    }
    if (usecount < 3) continue;
    int temp = (usecount - 3) * 10;
    for (int i = 0; i < 3; i++) {
      temp += abs(A[i] - nA[i]);
    }
    ans = min(ans, temp);
  } while (next(use));
  cout << ans << endl;
}
