#include <bits/stdc++.h>
using namespace std;
class State {
 public:
  int cost;
  vector<int> l;
  State(int nn, vector<int>& nnum) {
    cost = nn;
    l = nnum;
  }
  bool operator<(const State& s) const { return cost > s.cost; }
};
int main() {
  int n;
  int a[3];
  cin >> n >> a[0] >> a[1] >> a[2];
  vector<int> l;
  for (int i = 0; i < n; i++) {
    int ll;
    cin >> ll;
    l.push_back(ll);
  }
  priority_queue<State> v;
  v.push(State(0, l));
  int ans = 0;
  while (!v.empty()) {
    State s = v.top();
    v.pop();
    vector<int> ll = s.l;
    int cost = s.cost;
    bool fa, fb, fc;
    fa = fb = fc = false;
    for (int i = 0; i < ll.size(); i++) {
      if (!fa && a[0] == ll[i]) {
        fa = true;
        continue;
      }
      if (!fb && a[1] == ll[i]) {
        fb = true;
        continue;
      }
      if (!fc && a[2] == ll[i]) {
        fc = true;
        continue;
      }
    }
    if (fa && fb && fc) {
      ans = cost;
      break;
    }
    for (int j = 0; j < ll.size(); j++) {
      for (int i = 0; i < ll.size(); i++) {
        if (j == i) continue;
        vector<int> lll;
        lll.push_back(ll[j] + ll[i]);
        for (int k = 0; k < ll.size(); k++) {
          if (k == j || k == i) continue;
          lll.push_back(ll[k]);
        }
        v.push(State(cost + 10, lll));
      }
    }
    for (int i = 0; i < ll.size(); i++) {
      for (int k = 0; k < 3; k++) {
        vector<int> lll = ll;
        int temp = a[k] - lll[i];
        lll[i] = temp + lll[i];
        if (lll[i] <= 0 || temp == 0) continue;
        v.push(State(cost + abs(temp), lll));
      }
    }
  }
  cout << ans << endl;
}
