#include <bits/stdc++.h>
using namespace std;
const int INF = 100000000;
int makefrom3(int a, int b, int c, int x, int y, int z) {
  int mn = min(min(x, y), z);
  int mx = max(max(x, y), z);
  int mid = x + y + z - (mn + mx);
  return abs(c - mn) + abs(b - mid) + abs(a - mx);
}
int main() {
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<int> take(n);
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    take.push_back(l);
  }
  int min = INF;
  for (int bit = 0; bit < (1 << n); bit++) {
    vector<int> s;
    int count = 0;
    int mp = INF;
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        s.push_back(take[i]);
        count++;
      }
    }
    if (count < 3) {
      continue;
    }
    if (count == 3) {
      mp = makefrom3(a, b, c, s[0], s[1], s[2]);
    } else {
    }
    if (mp < min) {
      min = mp;
    }
  }
  cout << min << endl;
  return 0;
}
