#include <bits/stdc++.h>
using namespace std;
template <class T, class S>
void cmin(T &a, const S &b) {
  if (a > b) a = b;
}
signed main() {
  int n, A, B, C;
  cin >> n >> A >> B >> C;
  vector<int> v(n);
  for (auto &e : v) cin >> e;
  sort(v.begin(), v.end());
  int ans = (sizeof(int) == 4 ? (int)1e9 : (int)1e18);
  do {
    for (int l = 3; l <= v.size(); l++) {
      int a = 0, b = 0, c = 0;
      for (int i = 0; i < l - 2; i++) {
        a += v[i] + (i ? 10 : 0);
        for (int j = i + 1; j < l - 1; j++) {
          b += v[j] + (j - i - 1 ? 10 : 0);
          for (int k = j + 1; k < l; k++) {
            c += v[k] + (k - j - 1 ? 10 : 0);
          }
          cmin(ans, abs(A - a) + abs(B - b) + abs(C - c));
        }
      }
    }
  } while (next_permutation(v.begin(), v.end()));
  cout << ans << endl;
}
