#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, orig_a, orig_b, orig_c;
  cin >> n >> orig_a >> orig_b >> orig_c;
  int L[n + 2];
  for (int i = 0; i < n; ++i) {
    cin >> L[i];
  }
  L[n] = L[n + 1] = 0;
  sort(L, L + n + 2);
  int min_m = 8001;
  do {
    int a = orig_a;
    int b = orig_b;
    int c = orig_c;
    int m = 0;
    int i = 0;
    vector<int> a_vec;
    for (; i < n - 2; ++i) {
      if (L[i] == 0) break;
      a_vec.push_back(L[i]);
    }
    if (a_vec.empty()) continue;
    if (L[0] == 98 && L[1] == 0 && L[2] == 80 && L[3] == 0) {
      cout << "";
    }
    for (int j = 0; j < a_vec.size(); ++j) {
      if (a <= a_vec[j] || j + 1 == a_vec.size()) {
        m += abs(a_vec[j] - a);
        break;
      }
      if ((a - a_vec[j]) * 2 <= a_vec[j] + a_vec[j + 1]) {
        m += a - a_vec[j];
        break;
      }
      a -= a_vec[j];
      m += 10;
    }
    i++;
    vector<int> b_vec;
    for (; i < n; ++i) {
      if (L[i] == 0) break;
      b_vec.push_back(L[i]);
    }
    if (b_vec.empty()) continue;
    for (int j = 0; j < b_vec.size(); ++j) {
      if (b <= b_vec[j] || j + 1 == b_vec.size()) {
        m += abs(b_vec[j] - b);
        break;
      }
      if ((b - b_vec[j]) * 2 <= b_vec[j] + b_vec[j + 1]) {
        m += b - b_vec[j];
        break;
      }
      b -= b_vec[j];
      m += 10;
    }
    i++;
    vector<int> c_vec;
    for (; i < n + 2; ++i) {
      if (L[i] == 0) break;
      c_vec.push_back(L[i]);
    }
    if (c_vec.empty()) continue;
    for (int j = 0; j < c_vec.size(); ++j) {
      if (c <= c_vec[j] || j + 1 == c_vec.size()) {
        m += abs(c_vec[j] - c);
        break;
      }
      if ((c - c_vec[j]) * 2 <= c_vec[j] + c_vec[j + 1]) {
        m += c - c_vec[j];
        break;
      }
      c -= c_vec[j];
      m += 10;
    }
    if (m == 22) {
      cout << "";
    }
    min_m = min(min_m, m);
  } while (next_permutation(L, L + n + 2));
  cout << min_m << '\n';
  return 0;
}
