#include <bits/stdc++.h>
using namespace std;
int n;
int l[10];
int req[5];
bool used[10];
bool choose[10];
int could[100000];
int cdtp;
int closest(int q) {
  int *p = lower_bound(l + 1, l + n + 1, q);
  int l = *(p - 1), r = *p;
  if (q - l < r - q) {
    return l;
  }
  return r;
}
int closest2(int q) {
  int *p = lower_bound(could + 1, could + cdtp + 1, q);
  int l = *(p - 1), r = *p;
  if (q - l < r - q) {
    return l;
  }
  return r;
}
int main() {
  cin >> n >> req[1] >> req[2] >> req[3];
  for (int i = 1; i <= n; i++) cin >> l[i];
  sort(l + 1, l + n + 1);
  int ans = 0;
  int least[5];
  int leastid[5];
  memset(least, 63, sizeof(least));
  memset(leastid, -1, sizeof(leastid));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 3; j++) {
      if (req[j] < l[i]) {
        int exde = l[i] - req[j];
        if (abs(l[i] + closest(exde) - req[j]) >= exde) {
          least[j] = min(least[j], exde);
          if (least[j] == exde) leastid[j] = i;
        }
      }
    }
  }
  for (int i = 1; i <= 3; i++)
    if (leastid[i] > 0) used[leastid[i]] = true;
  vector<int> free;
  for (int i = 1; i <= n; i++)
    if (!used[i]) free.push_back(i);
  int totsum, lastsum;
  while (!choose[0]) {
    totsum = lastsum;
    for (int i = free.size() - 1; i >= 0; i--) {
      if (choose[i]) {
        choose[i] = false;
        totsum -= free[i];
      } else {
        totsum += free[i];
        choose[i] = true;
        break;
      }
    }
    if (choose[0]) break;
    could[++cdtp] = (totsum);
    lastsum = totsum;
  }
  sort(could + 1, could + cdtp + 1);
  for (int i = 1; i <= 3; i++) {
    if (least[i] > n) {
      least[i] = abs(req[i] - closest2(req[i]));
    }
  }
  cout << least[1] + least[2] + least[3];
  return 0;
}
