#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(3);
  for (int i = 0; i < 3; i++) cin >> a[i];
  sort(a.begin(), a.end());
  vector<int> l(n);
  for (int i = 0; i < n; i++) cin >> l[i];
  sort(l.begin(), l.end());
  long long ans = 10000000000008;
  for (int i = 0; i <= n - 3; i++) {
    for (int j = 1; j <= n - i - 2; j++) {
      for (int k = 1; k <= n - i - j - 1; k++) {
        int m = n - i - j - k;
        vector<int> per(n);
        for (int p = 0; p < n; p++) per[p] = p;
        do {
          long long tmp;
          tmp = 10 * (j - 1) + 10 * (k - 1) + 10 * (m - 1);
          long long tmpa = 0;
          long long tmpb = 0;
          long long tmpc = 0;
          for (int ii = 1; ii <= n - i; ii++) {
            if (ii <= j)
              tmpa += l[per[ii - 1]];
            else if (ii <= j + k)
              tmpb += l[per[ii - 1]];
            else
              tmpc += l[per[ii - 1]];
          }
          tmp += abs(tmpa - a[0]) + abs(tmpb - a[1]) + abs(tmpc - a[2]);
          ans = min(ans, tmp);
        } while (next_permutation(per.begin(), per.end()));
        cout << i << " : " << j << " : " << k << " : " << m << " = "
             << i + j + k + m << endl;
      }
    }
  }
  cout << ans << endl;
}
