#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  long long near_c = LLONG_MAX, near_b = LLONG_MAX, near_a = LLONG_MAX;
  long long near_c_index = -1, near_b_index = -1, near_a_index = -1;
  long long res = 0;
  for (long long i = 0; i < n; i++) {
    if (v[i] <= c && c - v[i] < abs(c - near_c)) {
      near_c = v[i];
      near_c_index = i;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (v[i] <= b && b - v[i] < abs(b - near_b) && i != near_c_index) {
      near_b = v[i];
      near_b_index = i;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (v[i] <= a && a - v[i] < abs(a - near_a) && i != near_c_index &&
        i != near_b_index) {
      near_a = v[i];
      near_a_index = i;
    }
  }
  set<long long> use_index;
  for (long long i = 0; i < n; i++) {
    if (i == near_c_index || near_b_index == i || i == near_a_index) continue;
    if (use_index.count(i) == 1) continue;
    if (abs(c - near_c) <= 10) break;
    if (c - near_c > abs(c - (near_c + v[i])) + 10 && v[i] > 10) {
      res += 10;
      near_c += v[i];
      use_index.insert(i);
    }
  }
  res += abs(c - near_c);
  for (long long i = 0; i < n; i++) {
    if (i == near_c_index || near_b_index == i || i == near_a_index) continue;
    if (use_index.count(i) == 1) continue;
    if (abs(b - near_b) <= 10) break;
    if (b - near_b > abs(b - (near_b + v[i])) + 10 && v[i] > 10) {
      res += 10;
      near_b += v[i];
      use_index.insert(i);
    }
  }
  res += abs(b - near_b);
  for (long long i = 0; i < n; i++) {
    if (i == near_c_index || near_b_index == i || i == near_a_index) continue;
    if (use_index.count(i) == 1) continue;
    if (abs(a - near_a) <= 10) break;
    if (a - near_a > abs(a - (near_a + v[i])) + 10 && v[i] > 10) {
      res += 10;
      near_a += v[i];
      use_index.insert(i);
    }
  }
  res += abs(a - near_a);
  cout << res << endl;
}
