#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) { return INT_MAX; }
double __vmax(double x) { return 1e+300; }
ll __vmax(ll x) { return LLONG_MAX; }
int __vmin(int x) { return INT_MIN; }
double __vmin(double x) { return -1e+300; }
ll __vmin(ll x) { return LLONG_MIN; }
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
int n, a, b, c, l[10];
int cost(vector<int> v, int t) {
  int sum = 0;
  for (auto&& v : v) sum += v;
  return abs(sum - t) + (v.size() - 1) * 10;
}
int re(vector<int> v) {
  if (v.size() < n) {
    auto v1 = v, v2 = v, v3 = v, v4 = v;
    v1.push_back(0);
    v2.push_back(1);
    v3.push_back(2);
    v4.push_back(3);
    return min(min(re(v1), re(v4)), min(re(v2), re(v3)));
  }
  vector<int> g[4];
  for (int i = 0; i < n; i++) g[v[i]].push_back(l[i]);
  if (g[0].size() * g[1].size() * g[2].size() == 0) return INT_MAX;
  return cost(g[0], a) + cost(g[1], b) + cost(g[2], c);
}
int main() {
  cin >> n >> a >> b >> c;
  for (int i = 0; i < n; i++) cin >> l[i];
  vector<int> v;
  cout << re(v) << endl;
}
