#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
void dbg() { cerr << "\n"; }
template <typename T, typename... T2>
void dbg(const T& fst, const T2&... rst) {
  cerr << fst << ": ";
  dbg(rst...);
}
template <class T>
void amin(T& a, T b) {
  a = min(a, b);
}
template <class T>
void amax(T& a, T b) {
  a = max(a, b);
}
int main() {
  int n;
  vector<int> a(3);
  cin >> n >> a[0] >> a[1] >> a[2];
  vector<int> l(n);
  for (int(i) = 0; (i) < (n); (i)++) cin >> l[i];
  int cnd = 0;
  for (int(i) = 0; (i) < (n); (i)++) {
    int amp = 999999999;
    for (int(j) = 0; (j) < (3); (j)++) {
      amp = min(amp, abs(a[j] - l[i]));
    }
    cnd += amp;
  }
  int ans = 1 << 28;
  int pj = 4;
  for (int(i) = 0; (i) < ((int)pow(pj, n)); (i)++) {
    vector<int> vi(n);
    for (int j = 0, wki = i; j < n; j++, wki /= pj) {
      vi[n - 1 - j] = wki % pj;
    }
    vector<int> sm(4), cnt(4);
    for (int(j) = 0; (j) < (n); (j)++) {
      sm[vi[j]] += l[j];
      cnt[vi[j]]++;
    }
    int msm = accumulate((l).begin(), (l).end(), 0);
    vector<int> ssx = {0, 1, 2, 3};
    do {
      auto q = ssx;
      vector<int> ss = {0, 1, 2};
      do {
        int sk = 0;
        for (int(k) = 0; (k) < (3); (k)++) {
          sk += abs(sm[q[k]] - a[ss[k]]);
          if (cnt[q[k]] > 1) sk += (cnt[q[k]] - 1) * 10;
        }
        ans = min(ans, sk);
      } while (next_permutation((ss).begin(), (ss).end()));
    } while (next_permutation((ssx).begin(), (ssx).end()));
  }
  cout << min(cnd, ans) << "\n";
  return 0;
}
