#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int IINF = INT_MAX;
const long long LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-11;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
int n, l[10], a[3];
int rec(int i, int m, vector<int> &v) {
  int res = IINF;
  if (m == 0) {
    int tmp = 0;
    for (int j = 0; j < 3; j++) tmp += abs(a[j] - v[j]);
    tmp += (i - 3) * 10;
    res = min(res, tmp);
  }
  if (i >= n)
    return IINF;
  else {
    v.push_back(l[i]);
    res = min(res, rec(i + 1, m - 1, v));
    v.pop_back();
    if (m < 3) {
      v.back() += l[i];
      res = min(res, rec(i + 1, m, v));
      v.back() -= l[i];
    }
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 0; i < 3; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> l[i];
  sort(a, a + 3);
  sort(l, l + n);
  int ans = IINF;
  vector<int> v;
  while (1) {
    ans = min(ans, rec(0, 3, v));
    if (!next_permutation(l, l + n)) break;
  }
  cout << ans << endl;
  return 0;
}
