#include <bits/stdc++.h>
using namespace std;
int n, res = 0;
int a[3];
bool flag;
int inf = 9999999;
vector<int> l;
pair<int, vector<int>> solve(int num, int mp, vector<int> &take) {
  vector<int> ll;
  ll = take;
  int m = 99999;
  int idx = 0;
  for (int i = 0; i < ll.size(); i++) {
    flag = false;
    if (m > abs(num - ll[i])) {
      idx = i;
      m = abs(num - ll[i]);
    }
    if (num > ll[i]) {
      flag = true;
    }
  }
  if (m <= 10 || !flag || ll.size() == 1) {
    ll.erase(ll.begin() + idx);
    mp += m;
    return make_pair(mp, ll);
  } else {
    pair<int, vector<int>> ans;
    ans.first = 999999999;
    for (int j = 0; j < ll.size() - 1; j++) {
      for (int k = j + 1; k < ll.size(); k++) {
        vector<int> new_l;
        for (int q = 0; q < ll.size() - 1; q++) {
          if (q != j && q != k) {
            new_l.push_back(ll[q]);
          }
        }
        new_l.push_back(ll[j] + ll[k]);
        pair<int, vector<int>> tmp;
        tmp = solve(num, mp + 10, new_l);
        if (tmp.first < ans.first) {
          ans = tmp;
        }
      }
    }
    return ans;
  }
}
int main() {
  cin >> n >> a[0] >> a[1] >> a[2];
  for (int i = 0; i < n; i++) {
    flag = true;
    int tmp;
    cin >> tmp;
    for (int j = 0; j < 3; j++) {
      if (tmp == a[j]) {
        a[j] = -1;
        flag = false;
        break;
      }
    }
    if (flag) {
      l.push_back(tmp);
    }
  }
  for (int i = 0; i < 3; i++) {
    if (a[i] == -1) {
      continue;
    }
    int num = a[i];
    pair<int, vector<int>> ans = solve(num, 0, l);
    res += ans.first;
    l = ans.second;
  }
  cout << res;
  return 0;
}
