#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
ll a[3];
ll cost(ll x[3]) {
  return abs(a[0] - x[0]) + abs(a[1] - x[1]) + abs(a[2] - x[2]);
}
ll func(ll a[], ll n) {
  ll minimum = 10000;
  ll x[3];
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        x[0] = a[i];
        x[1] = a[j];
        x[2] = a[k];
        sort(x, x + 3);
        cout << x[0] << " " << x[1] << " " << x[2] << " " << cost(x) << endl;
        minimum = min(minimum, cost(x));
      }
    }
  }
  ll b[n];
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = 0; k < n; k++) {
        b[k] = a[k];
      }
      b[i] += b[j];
      b[j] = b[n - 1];
      minimum = min(minimum, 10 + func(b, n - 1));
    }
  }
  return minimum;
}
int main() {
  ll n;
  cin >> n >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  ll l[n];
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  cout << func(l, n);
}
