#include <bits/stdc++.h>
using namespace std;
int n, A, B, C;
long long ans = 1e6;
void sol(vector<int> v, long long acum) {
  bool visited[v.size()];
  memset(visited, false, sizeof visited);
  long long aux = acum;
  long long dif, ind;
  dif = 100000;
  ind = -1;
  for (int i = 0; i < v.size(); i++) {
    if (visited[i] == false && abs(v[i] - A) < dif) {
      dif = abs(v[i] - A);
      ind = i;
    }
  }
  aux += dif;
  visited[ind] = true;
  dif = 100000;
  ind = -1;
  for (int i = 0; i < v.size(); i++) {
    if (visited[i] == false && abs(v[i] - B) < dif) {
      dif = abs(v[i] - B);
      ind = i;
    }
  }
  aux += dif;
  visited[ind] = true;
  dif = 100000;
  ind = -1;
  for (int i = 0; i < v.size(); i++) {
    if (visited[i] == false && abs(v[i] - C) < dif) {
      dif = abs(v[i] - C);
      ind = i;
    }
  }
  aux += dif;
  visited[ind] = true;
  ans = min(ans, aux);
  if (v.size() == 3) {
    return;
  }
  for (int i = 0; i < v.size(); i++) {
    for (int j = i + 1; j < v.size(); j++) {
      vector<int> s1;
      s1.push_back(v[i] + v[j]);
      for (int k = 0; k < v.size(); k++) {
        if (k != i && k != j) {
          s1.push_back(v[k]);
        }
      }
      sol(s1, acum + 10);
    }
  }
}
int main() {
  scanf("%d %d %d %d", &n, &A, &B, &C);
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%lld", &a);
    v.push_back(a);
  }
  sol(v, 0);
  cout << ans << endl;
  return 0;
}
