#include <bits/stdc++.h>
using namespace std;
long long N, A[3];
vector<long long> l, v;
long long ans = 1LL << 62;
void calc() {
  long long sum[3] = {};
  long long cnt[3] = {};
  for (long long i = 0; i < v.size(); i++) {
    if (v[i] < 3) {
      sum[v[i]] += l[i];
      cnt[v[i]]++;
    }
  }
  bool f = true;
  long long ret = 0;
  for (long long i = 0; i < 3; i++) {
    f &= !!cnt[i];
    ret += abs(sum[i] - A[i]);
    ret += max(0LL, (cnt[i] - 1) * 10);
  }
  if (!f) return;
  ans = min(ans, ret);
}
void dfs(long long depth) {
  if (depth == 8) {
    calc();
    return;
  }
  for (long long i = 0; i < 4; i++) {
    v[depth] = i;
    dfs(depth + 1);
  }
}
signed main() {
  cin >> N >> A[0] >> A[1] >> A[2];
  l.resize(N);
  for (long long& x : l) cin >> x;
  v.resize(N, -1);
  dfs(0);
  cout << ans << endl;
  return 0;
}
