#include <bits/stdc++.h>
inline void rep(int n, std::function<void(int)> f) {
  for (int i = 0; i < n; i++) {
    f(i);
  }
};
void myerase(std::vector<int>& v, int e) {
  int tmp = v.at(e);
  v.at(e) = v.back();
  v.pop_back();
}
bool isnmin(std::vector<int> v, int n) {
  for (const auto& e : v) {
    if (e < n) {
      return false;
    }
  }
  return true;
}
bool mp10(std::vector<int>& v, int length, int pminnis) {
  int x, y, mindis = 10000;
  int vsize = static_cast<int>(v.size());
  for (int i = 0; i < vsize - 1; i++) {
    for (int k = i + 1; k < vsize; k++) {
      int dis = std::abs(length - v[i] - v[k]);
      if (dis < mindis) {
        mindis = dis;
        x = i;
        y = k;
      }
    }
  }
  if (mindis + 10 < pminnis) {
    v.at(y) += v.at(x);
    myerase(v, x);
    return true;
  }
  return false;
}
int f1(std::vector<int>& v, int length, int mpmax, int min) {
  int i = 0, mindis = 10000, tmpi = 0;
  for (const auto& e : v) {
    if (length == e) {
      myerase(v, i);
      return mpmax;
    } else {
      int dis = std::abs(length - e);
      if (dis <= mindis) {
        mindis = dis;
        tmpi = i;
      }
    }
    i++;
  }
  if (mindis < mpmax + 10) {
    myerase(v, tmpi);
    return mpmax + mindis;
  } else {
    if (isnmin(v, length)) {
      std::sort(v.begin(), v.end());
      int mp = v.at(0) - length;
      myerase(v, 0);
      return mpmax + mp;
    }
    if (static_cast<int>(v.size()) > min) {
      if (mp10(v, length, mindis)) {
        return f1(v, length, mpmax + 10, min);
      }
    }
    return mpmax + std::abs(length - v.at(tmpi));
  }
}
int baka(std::vector<int> v, int x, int y, int z) {
  int mp = 0;
  mp += f1(v, x, 0, 3);
  mp += f1(v, y, 0, 2);
  mp += f1(v, z, 0, 1);
  return mp;
}
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n, a, b, c, l;
  std::cin >> n >> a >> b >> c;
  std::cin.ignore();
  std::vector<int> v;
  rep(n, [&](int i) {
    std::cin >> l;
    v.push_back(l);
  });
  std::vector<int> mp;
  mp.push_back(baka(v, a, b, c));
  mp.push_back(baka(v, a, c, b));
  mp.push_back(baka(v, b, a, c));
  mp.push_back(baka(v, b, c, a));
  mp.push_back(baka(v, c, a, b));
  mp.push_back(baka(v, c, b, a));
  std::sort(mp.begin(), mp.end());
  std::cout << mp.at(0) << '\n';
  return 0;
}
