#include <bits/stdc++.h>
int N;
int a[3];
std::vector<int> l;
long calc(int obj) {
  long ans = 0;
  long total = 0;
  while (true) {
    std::sort(l.begin(), l.end(), std::greater<int>());
    int idx = -1;
    int diff = std::abs(obj - total);
    for (int i = 0; i < l.size() && l[i] != 10000; ++i) {
      int tmp = std::abs(total + l[i] - obj);
      if (diff > tmp) {
        diff = tmp;
        idx = i;
      }
    }
    if (diff <= 10) {
      ans += diff;
      l[idx] = -10000;
      return ans;
    } else if (l[idx] == 10000 || diff == std::abs(total - obj)) {
      ans += std::abs(total - obj);
      return ans;
    } else {
      ans += 10;
      total += l[idx];
      l[idx] = -10000;
    }
  }
  return ans;
}
void solve() {
  long ans = 0;
  for (int i = 0; i < 3; ++i) {
    if (a[i] == -10000) continue;
    ans += calc(a[i]);
  }
  std::cout << ans << std::endl;
}
int main() {
  std::cin >> N;
  for (int i = 0; i < 3; ++i) std::cin >> a[i];
  for (int i = 0; i < N; ++i) {
    int tmp;
    std::cin >> tmp;
    if (tmp == a[0])
      a[0] = -10000;
    else if (tmp == a[1])
      a[1] = -10000;
    else if (tmp == a[2])
      a[2] = -10000;
    else
      l.push_back(tmp);
  }
  solve();
  return 0;
}
