#include <bits/stdc++.h>
using namespace std;
int n, A, B, C;
int ans = 5000;
int arr[3];
void sol(vector<int> v, int acum) {
  bool visited[v.size()];
  memset(visited, false, sizeof visited);
  int aux = 0;
  sort(v.begin(), v.end());
  for (int i = 2; i >= 0; i--) {
    int dif = 5000;
    int ind = -1;
    for (int j = 0; j < v.size(); j++) {
      if (visited[j] == false && abs(v[j] - arr[i]) <= dif) {
        dif = abs(v[j] - arr[i]);
        ind = j;
      }
    }
    visited[ind] = true;
    aux += dif;
  }
  ans = min(ans, aux + acum);
  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, &arr[0], &arr[1], &arr[2]);
  sort(arr, arr + 3);
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    v.push_back(a);
  }
  sol(v, 0);
  cout << ans << endl;
  return 0;
}
