#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, A, l;
  int left, right;
  int left1, right1;
  int ans = 0;
  int min = 1000000;
  vector<int> L;
  vector<int> G;
  cin >> N;
  for (int i = 0; i < 3; i++) {
    cin >> A;
    G.push_back(A);
  }
  for (int i = 0; i < N; i++) {
    cin >> l;
    L.push_back(l);
  }
  for (int i = 0; i < G.size(); i++)
    for (int j = 0; j < L.size(); j++) {
      if (G[i] == L[j]) {
        G.erase(G.begin() + i);
        L.erase(L.begin() + j);
      }
    }
  for (int i = 0; i < G.size();) {
    for (int j = 0; j < L.size(); j++) {
      if (min > abs(G[i] - L[j])) {
        min = abs(G[i] - L[j]);
        left = j;
      }
    }
    for (int j = 0; j < L.size(); j++) {
      for (int k = j + 1; k < L.size(); k++) {
        if (min > abs(G[i] - (L[j] + L[k]))) {
          left1 = j;
          right1 = k;
          min = abs(G[i] - (L[j] + L[k]));
        }
      }
    }
    if (min < abs(G[i] - L[left]) && abs(G[i] - L[left]) > 10 &&
        L.size() > (G.size() - i)) {
      L[left1] += L[right1];
      ans += 10;
      L.erase(L.begin() + right1);
    } else {
      ans += abs(G[i] - L[left]);
      i++;
      L.erase(L.begin() + left);
    }
    min = 1000000;
  }
  cout << ans << endl;
  return 0;
}
