#include <bits/stdc++.h>
using namespace std;
int N, A, B, C;
vector<int> l;
int ans;
int setMp(vector<int> &list) {
  int res = 100000;
  for (int i = 0; i < list.size(); i++) {
    for (int j = 0; j < list.size(); j++) {
      if (i == j) continue;
      for (int k = 0; k < list.size(); k++) {
        if (j == k || i == k) continue;
        res = min(res, abs(A - list[i]) + abs(B - list[j]) + abs(C - list[k]));
      }
    }
  }
  return res;
}
void setTake(vector<int> &list, int cost) {
  if (list.size() <= 3 || cost >= ans) return;
  for (int i = 0; i < list.size(); i++) {
    for (int j = 0; j < list.size(); j++) {
      if (i == j) continue;
      if (list[i] + list[j] - A >= ans) continue;
      vector<int> nextList;
      for (int k = 0; k < list.size(); k++) {
        if (k == i || k == j) continue;
        nextList.push_back(list[k]);
      }
      nextList.push_back(list[i] + list[j]);
      ans = min(ans, setMp(nextList) + cost + 10);
      setTake(nextList, cost + 10);
    }
  }
  return;
}
int main() {
  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    l.push_back(x);
  }
  sort(l.begin(), l.end());
  ans = setMp(l);
  setTake(l, 0);
  cout << ans << endl;
  return 0;
}
