#include <bits/stdc++.h>
using namespace std;
using int32 = int32_t;
using str = string;
using cstr = const str;
using ll = long long;
using ull = unsigned long long;
using cint = const ll;
using cll = const ll;
using vi = vector<ll>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using pii = pair<ll, ll>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using psl = pair<string, ll>;
using tiii = tuple<ll, ll, ll>;
using tlll = tuple<ll, ll, ll>;
static const ll MGN = 10;
static const ll ARYSZ_MAX = (ll)1e7;
static const ll LINF = LLONG_MAX / 2;
static const ll INF = LINF;
static double EPS = 1e-9;
static inline bool DBLEQ(double a, double b) { return abs(a - b) < EPS; }
static inline void EPR(str msg) { cerr << msg << endl; }
static inline void AST(bool exp, str msg) {
  if (!exp) {
    EPR(msg);
  }
  assert(exp);
}
static inline void TAST(bool exp, str msg) {
  if (!exp) {
    EPR(msg);
  }
  while (!exp) {
  }
}
struct DFS {
  struct Param {
    ll val;
    ll count;
  };
  struct State {
    State(){};
    State(ll size) { (*this).params = vector<Param>(size); }
    vector<Param> params;
    vi path;
  };
  DFS(ll depth, const vi& Item, ll state_size, ll A, ll B, ll C) {
    (*this).DEPTH = depth;
    (*this).Item = Item;
    (*this).STATE_SIZE = state_size;
    (*this).st = State(state_size);
    (*this).A = A;
    (*this).B = B;
    (*this).C = C;
  }
  ll DEPTH;
  vi Item;
  ll STATE_SIZE;
  State st;
  ll ans;
  ll A, B, C;
  void _dfs(ll n, ll i, State& st) {
    if (n >= (*this).DEPTH) {
      ll cnt1 = st.params[1].count, cnt2 = st.params[2].count,
         cnt3 = st.params[3].count;
      if (cnt1 > 0 and cnt2 > 0 and cnt3 > 0) {
        ll cost = 10 * (cnt1 - 1) + 10 * (cnt2 - 1) + 10 * (cnt3 - 1) +
                  abs(st.params[1].val - A) + abs(st.params[2].val - B) +
                  abs(st.params[3].val - C);
        ans = min(ans, cost);
      }
      return;
    } else {
      st.params[i].val += Item[n];
      st.params[i].count += 1;
      st.path.push_back(i);
      for (ll j = ll(0); j < ll((*this).STATE_SIZE); ++j)
        (*this)._dfs(n + 1, j, (*this).st);
      st.params[i].val -= Item[n];
      st.params[i].count -= 1;
      st.path.pop_back();
    }
  }
  ll dfs(ll n = 0) {
    for (ll i = ll(0); i < ll((*this).STATE_SIZE); ++i)
      (*this)._dfs(n, i, (*this).st);
    return (*this).ans;
  }
};
int32 main(int32 argc, char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ;
  ;
  ll N, A, B, C;
  cin >> N >> A >> B >> C;
  auto L = vi(N);
  for (ll i = ll(0); i < ll(N); ++i) cin >> L[i];
  auto search = DFS(N, L, 4, A, B, C);
  ll ans = search.dfs(0);
  cout << ans << endl;
  return 0;
}
