#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = std::vector<T>;
template <class T>
using vvec = vec<vec<T>>;
constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }
int main() {
  using namespace std;
  int n;
  cin >> n;
  vec<int> abc(3), l(n);
  for (auto &e : abc) cin >> e;
  for (auto &e : l) cin >> e;
  sort(abc.begin(), abc.end());
  sort(l.begin(), l.end());
  vec<int> costs;
  do {
    for (int i = 1; i < n - 2; ++i)
      for (int j = i + 1; j < n - 1; ++j)
        for (int k = j + 1; k < n; ++k) {
          vec<int> v(3);
          int cost{(k - 2) * 10};
          for (int m = 0; m <= k; ++m) {
            if (m < i)
              v[0] += l[m];
            else if (m < j)
              v[1] += l[m];
            else
              v[2] += l[m];
          }
          sort(v.begin(), v.end());
          for (int m = 0; m < 3; ++m) cost += abs(v[m] - abc[m]);
          costs.push_back(cost);
        }
  } while (next_permutation(l.begin(), l.end()));
  sort(costs.begin(), costs.end());
  cout << costs.front() << endl;
  return 0;
}
