#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int A, B, C;
  cin >> N >> A >> B >> C;
  vector<pair<int, int>> L;
  for (int i = 0; i < N; ++i) {
    int L_i;
    cin >> L_i;
    L.push_back(pair<int, int>(L_i, 1));
  }
  for (int i = 0; i < N - 1; ++i) {
    for (int j = i + 1; j < N; ++j) {
      int L_add = L[i].first + L[j].first;
      L.push_back(pair<int, int>(L_add, 10));
      cout << L_add << endl;
    }
  }
  int MP_count = 0;
  int MP_A1 = A, MP_B1 = B, MP_C1 = C;
  for (int i = 0; i < N; ++i) {
    if (abs(A - L[i].first) < MP_A1) MP_A1 = abs(A - L[i].first);
    if (abs(B - L[i].first) < MP_B1) MP_B1 = abs(B - L[i].first);
    if (abs(C - L[i].first) < MP_C1) MP_C1 = abs(C - L[i].first);
  }
  int MP_A2 = A, MP_B2 = B, MP_C2 = C;
  for (int i = N; i < (int)L.size(); ++i) {
    int tmp_A = abs(A - L[i].first) + L[i].second;
    int tmp_B = abs(B - L[i].first) + L[i].second;
    int tmp_C = abs(C - L[i].first) + L[i].second;
    if (tmp_A < MP_A2) MP_A2 = tmp_A;
    if (tmp_B < MP_B2) MP_B2 = tmp_B;
    if (tmp_C < MP_C2) MP_C2 = tmp_C;
  }
  MP_count = min(MP_A1, MP_A2) + min(MP_B1, MP_B2) + min(MP_C1, MP_C2);
  cout << MP_count << endl;
  return 0;
}
