#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;
}
template <class T>
void combination(const std::vector<T>& seed, std::vector<int>& takes,
                 int target_size, int& mindis, int target, int& newtake) {
  std::vector<int> indices(target_size);
  const int seed_size = static_cast<int>(seed.size());
  int start_index = 0;
  int size = 0;
  while (size >= 0) {
    for (int i = start_index; i < seed_size; ++i) {
      indices[size++] = i;
      if (size == target_size) {
        std::vector<T> comb(target_size);
        int sum = 0;
        for (int x = 0; x < target_size; ++x) {
          comb[x] = seed[indices[x]];
          sum += seed[indices[x]];
        }
        int dis = std::abs(sum - target);
        std::vector<int> tmp;
        if (dis < mindis) {
          mindis = dis;
          takes = comb;
          newtake = sum;
        }
        break;
      }
    }
    --size;
    if (size < 0) break;
    start_index = indices[size] + 1;
  }
}
bool gattai(std::vector<int>& v, int length, int& mindis, int min, int& size) {
  int x, y;
  int kazu = mindis / 10;
  int vsize = static_cast<int>(v.size());
  int newtake = 0;
  std::vector<int> takes;
  for (int i = 2; i <= kazu; i++) {
    if (i > vsize - min + 1) {
      break;
    }
    std::vector<int> tmpv = v;
    combination(tmpv, takes, i, mindis, length, newtake);
  }
  size = static_cast<int>(takes.size());
  if (size > 1) {
    for (const auto& e : takes) {
      int i = 0;
      for (const auto& s : v) {
        if (e == s) {
          myerase(v, i);
          break;
        }
        i++;
      }
    }
    v.push_back(newtake);
    return true;
  }
  return false;
}
int f1(std::vector<int>& v, int length, int min) {
  int i = 0, mindis = 10000, tmpi = 0;
  for (const auto& e : v) {
    if (length == e) {
      myerase(v, i);
      return 0;
    } else {
      int dis = std::abs(length - e);
      if (dis <= mindis) {
        mindis = dis;
        tmpi = i;
      }
    }
    i++;
  }
  if (mindis <= 10) {
    myerase(v, tmpi);
    return mindis;
  } else {
    if (isnmin(v, length)) {
      std::sort(v.begin(), v.end());
      int mp = v.at(0) - length;
      myerase(v, 0);
      return mp;
    }
    if (static_cast<int>(v.size()) > min) {
      int gattaisu = 0;
      if (gattai(v, length, mindis, min, gattaisu)) {
        return (gattaisu - 1) * 10 + mindis;
      }
    }
    myerase(v, tmpi);
    return mindis;
  }
}
int baka(std::vector<int> v, int x, int y, int z) {
  int mp = 0;
  mp += f1(v, x, 3);
  mp += f1(v, y, 2);
  mp += f1(v, z, 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;
}
