#include <bits/stdc++.h>
using namespace std;
int inputValue() {
  int a;
  cin >> a;
  return a;
};
template <typename T>
void inputArray(T* p, int a) {
  for (int i = (0); i < (a); i++) {
    cin >> p[i];
  }
};
template <typename T>
void inputVector(vector<T>* p, int a) {
  for (int i = (0); i < (a); i++) {
    T input;
    cin >> input;
    p->push_back(input);
  }
}
template <typename T>
void output(T a, int precision = 0) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  } else {
    cout << a << "\n";
  }
}
int N, A, B, C;
int l[10];
int dABC[3][10];
vector<int> ls;
int search_min(int n, int* r, int* l, int exr1, int exr2, int exl1, int exl2) {
  int minval = 10000000;
  for (int i = (0); i < (3); i++) {
    for (int j = (0); j < (n); j++) {
      if (i == exr1 || i == exr2) continue;
      if (j == exl1 || j == exl2) continue;
      if (dABC[i][j] < minval) {
        minval = dABC[i][j];
        *r = i;
        *l = j;
      }
    }
  }
  return minval;
}
int calc() {
  int n = ls.size();
  for (int i = (0); i < (ls.size()); i++) {
    dABC[0][i] = abs(ls[i] - A);
    dABC[1][i] = abs(ls[i] - B);
    dABC[2][i] = abs(ls[i] - C);
  }
  int ans = 0;
  int exr1 = -1;
  int exr2 = -1;
  int exl1 = -1;
  int exl2 = -1;
  ans += search_min(n, &exr1, &exl1, exr1, exr2, exl1, exl2);
  ans += search_min(n, &exr2, &exl2, exr1, exr2, exl1, exl2);
  ans += search_min(n, &exr2, &exl2, exr1, exr2, exl1, exl2);
  return ans;
}
int pick2(int max, int count) {
  if (count == max) return calc() + 10 * count;
  int n = ls.size();
  int ans = 10000000;
  for (int t1 = (0); t1 < (n); t1++) {
    for (int t2 = (0); t2 < (n); t2++) {
      if (t1 == t2) continue;
      int tmp1 = ls[t1];
      int tmp2 = ls[t2];
      if (t1 > t2) {
        ls.erase(ls.begin() + t1);
        ls.erase(ls.begin() + t2);
      } else {
        ls.erase(ls.begin() + t2);
        ls.erase(ls.begin() + t1);
      }
      ls.push_back(tmp1 + tmp2);
      ans = min(ans, pick2(max, count + 1));
      ls.pop_back();
      if (t1 > t2) {
        ls.insert(ls.begin() + t2, tmp2);
        ls.insert(ls.begin() + t1, tmp1);
      } else {
        ls.insert(ls.begin() + t1, tmp1);
        ls.insert(ls.begin() + t2, tmp2);
      }
    }
  }
  return ans;
}
int main(int argc, const char* argv[]) {
  N = inputValue();
  A = inputValue();
  B = inputValue();
  C = inputValue();
  inputArray(l, N);
  for (int i = (0); i < (N); i++) {
    ls.push_back(l[i]);
  }
  int ans = calc();
  for (int i = (1); i < (N - 3 + 1); i++) {
    ans = min(ans, pick2(i, 0));
  }
  output(ans);
  return 0;
}
