#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a(3), l(10);
vector<bool> lbool(10), abool(3);
int main() {
  cin >> n;
  for (int i = 0; i < (3); i++) cin >> a[i];
  for (int i = 0; i < (n); i++) cin >> l[i];
  int sumcost = 0;
  while (!(abool[0] && abool[1] && abool[2])) {
    vector<int> minc(3);
    vector<vector<int>> minv(3);
    for (int i = 0; i < (((int)(a).size())); i++) {
      int mincost = INT_MAX;
      vector<int> minvec;
      for (int bit = 1; bit < (1 << n); bit++) {
        vector<int> acl, aci;
        for (int i = 0; i < (n); i++)
          if (bit & (1 << i) && !lbool[i]) {
            acl.push_back(l[i]);
            aci.push_back(i);
          }
        int sum = accumulate((acl).begin(), (acl).end(), 0);
        int nowcost = abs(a[i] - sum) + 10 * (((int)(aci).size()) - 1);
        if (mincost > nowcost && ((int)(aci).size()) != 0) {
          mincost = nowcost;
          minvec = aci;
        }
      }
      minc[i] = mincost;
      minv[i] = minvec;
    }
    int mini, minin = INT_MAX;
    for (int i = 0; i < (3); i++) {
      if (minin > minc[i] && !abool[i]) {
        mini = i;
        minin = minc[i];
      }
    }
    vector<int> era = minv[mini];
    for (int i = 0; i < (((int)(era).size())); i++) {
      lbool[era[i]] = true;
    }
    sumcost += minc[mini];
    abool[mini] = true;
  }
  cout << sumcost << endl;
}
