#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  bool hantei_a = false;
  bool hantei_b = false;
  bool hantei_c = false;
  int a_min = INT_MAX;
  int b_min = INT_MAX;
  int c_min = INT_MAX;
  for (int i = 0; i < n; i++) {
    if (h.at(i) == a) {
      hantei_a = true;
      h.at(i) = INT_MAX;
    } else if (h.at(i) == b) {
      hantei_b = true;
      h.at(i) = INT_MAX;
    } else if (h.at(i) == c) {
      hantei_c = true;
      h.at(i) = INT_MAX;
    } else {
      a_min = min(a_min, abs(a - h.at(i)));
      b_min = min(b_min, abs(b - h.at(i)));
      c_min = min(c_min, abs(c - h.at(i)));
    }
  }
  if (hantei_a == true && hantei_b == true && hantei_c == true) {
    cout << 0 << endl;
  } else {
    if (hantei_a == true) a_min = 0;
    if (hantei_b == true) b_min = 0;
    if (hantei_c == true) c_min = 0;
    cout << a_min + b_min + c_min << endl;
  }
  return 0;
}
