#include <bits/stdc++.h>
using namespace std;
int find(int num, vector<int> &list) {
  vector<int> diff(list.size());
  for (int i = 0; i < list.size(); i++) {
    diff[i] = abs(list[i] - num);
  }
  auto iter = min_element(diff.begin(), diff.end());
  int index = distance(diff.begin(), iter);
  return index;
}
int cost(int tgt, vector<int> &list) {
  int index = find(tgt, list);
  int diff = abs(tgt - list[index]);
  if (diff <= 10) {
    return diff;
  } else {
    list[index] = 99999;
    return cost(diff, list) + 10;
  }
}
int main(const int argc, const char **argv) {
  int N, A, B, C;
  scanf("%d %d %d %d", &N, &A, &B, &C);
  vector<int> l(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &l[i]);
  }
  int ans = 0;
  vector<int> la(N), lb(N), lc(N);
  for (int i = 0; i < N; i++) {
    la[i] = l[i];
    lb[i] = l[i];
    lc[i] = l[i];
  }
  int cost_A = cost(A, la);
  int cost_B = cost(B, lb);
  int cost_C = cost(C, lc);
  std::vector<int> costs{cost_A, cost_B, cost_C};
  auto iter = min_element(costs.begin(), costs.end());
  int index = distance(costs.begin(), iter);
  if (index == 0) {
    ans += cost_A;
    vector<int> lb(N), lc(N);
    for (int i = 0; i < N; i++) {
      lb[i] = l[i];
      lc[i] = l[i];
    }
    int cost_B = cost(B, lb);
    int cost_C = cost(C, lc);
    std::vector<int> costs{cost_B, cost_C};
    auto iter = min_element(costs.begin(), costs.end());
    int index = distance(costs.begin(), iter);
    if (index == 1) {
      ans += cost_B;
      ans += cost(C, lb);
    } else if (index == 2) {
      ans += cost_C;
      ans += cost(B, lc);
    }
  } else if (index == 1) {
    ans += cost_B;
    vector<int> la(N), lc(N);
    for (int i = 0; i < N; i++) {
      la[i] = l[i];
      lc[i] = l[i];
    }
    int cost_A = cost(A, la);
    int cost_C = cost(C, lc);
    std::vector<int> costs{cost_A, cost_C};
    auto iter = min_element(costs.begin(), costs.end());
    int index = distance(costs.begin(), iter);
    if (index == 0) {
      ans += cost_A;
      ans += cost(C, la);
    } else if (index == 2) {
      ans += cost_C;
      ans += cost(A, lc);
    }
  } else if (index == 2) {
    ans += cost_C;
    vector<int> la(N), lb(N);
    for (int i = 0; i < N; i++) {
      la[i] = l[i];
      lb[i] = l[i];
    }
    int cost_A = cost(A, la);
    int cost_B = cost(B, lb);
    std::vector<int> costs{cost_A, cost_B};
    auto iter = min_element(costs.begin(), costs.end());
    int index = distance(costs.begin(), iter);
    if (index == 1) {
      ans += cost_B;
      ans += cost(A, lb);
    } else if (index == 0) {
      ans += cost_A;
      ans += cost(B, la);
    }
  }
  printf("%d", ans);
  return 0;
}
