// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for (int i=0; i<(int)(n); ++i)

#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)

#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)

#define ALL(a) (a).begin(), (a).end()

#define RALL(a) (a).rbegin(), (a).rend()

using ll = long long;

using vi = vector<int>;

using vl = vector<ll>;

using Graph = vector<vi>;  // vi <=> vl

using vb = vector<bool>;

using boolGraph = vector<vb>;

using P = pair<int, int>;  // int <=> ll

const int MOD = 1e9+7;

const int MOD2 = 998244353;

const double EPS = 1e-9;



template<typename T>

struct is_vector : false_type{};



template<typename T>

struct is_vector<vector<T>> : true_type{};



template<typename T>

ostream &operator << (ostream &ostr, const vector<T> &vec) {

  if (vec.empty()) {

    return ostr;

  }

  ostr << vec.front();

  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {

    if (is_vector<T>()) ostr << "\n" << *itr;

    else ostr << ' ' << *itr;

  }

  return ostr;

}



void solve() {

  int n, a, b, c; cin >> n >> a >> b >> c;

  vi target = {a, b, c};

  vi arr(n);

  rep(i,n) cin >> arr[i];



  vi perm(n);

  rep(i,n) perm[i] = i;



  int ans = 1e4;



  do {

    for (int i=2; i<n; ++i) {

      Graph G(3);

      for (int k=i; k<n; ++k) G[0].push_back(arr[perm[k]]);



      for (int j=1; j<i; ++j) {

        G[1].clear(); G[2].clear();

        for (int k=j; k<i; ++k) G[1].push_back(arr[perm[k]]);

        for (int k=0; k<j; ++k) G[2].push_back(arr[perm[k]]);



        vi mp(3, 1e4);

        rep(k,3) {

          rep1(tmp,(1<<G[k].size())-1) {

            bitset<8> s(tmp);

            int p = 0;

            p += 10 * (s.count() - 1);

            int sz = 0;

            rep(l,G[k].size()) if (s[l]) sz += G[k][l];

            p += abs(target[k] - sz);



            mp[k] = min(mp[k], p);

          }

        }



        ans = min(ans, accumulate(ALL(mp), 0));

      }

    }

  } while (next_permutation(ALL(perm)));



  cout << ans << endl;

}



int main() {

  cin.tie(nullptr);

  ios::sync_with_stdio(false);

  cout << fixed << setprecision(12);

  solve();

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.1370912628253933x):
#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for (int i=0; i<(int)(n); ++i)

#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)

#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)

#define ALL(a) (a).begin(), (a).end()

#define RALL(a) (a).rbegin(), (a).rend()

using ll = long long;

using vi = vector<int>;

using vl = vector<ll>;

using Graph = vector<vi>;  // vi <=> vl

using vb = vector<bool>;

using boolGraph = vector<vb>;

using P = pair<int, int>;  // int <=> ll

const int MOD = 1e9+7;

const int MOD2 = 998244353;

const double EPS = 1e-9;



template<typename T>

struct is_vector : false_type{};



template<typename T>

struct is_vector<vector<T>> : true_type{};



template<typename T>

ostream &operator << (ostream &ostr, const vector<T> &vec) {

  if (vec.empty()) {

    return ostr;

  }

  ostr << vec.front();

  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {

    if (is_vector<T>()) ostr << "\n" << *itr;

    else ostr << ' ' << *itr;

  }

  return ostr;

}



void solve() {

  int n, a, b, c; cin >> n >> a >> b >> c;

  vi target = {a, b, c};

  vi arr(n);

  rep(i,n) cin >> arr[i];



  int ans = 1e4;

  rep(tmp,(1<<(2*n))) {

    bitset<16> s(tmp);



    vi cnt(4, 0), sum(4, 0);

    rep(i,n) {

      int j = s[2*i] + 2 * s[2*i+1];

      ++cnt[j];

      sum[j] += arr[i];

    }

    if (cnt[0] * cnt[1] * cnt[2] == 0) continue;



    int mp = 0;

    rep(i,3) {

      mp += 10 * (cnt[i] - 1);

      mp += abs(sum[i] - target[i]);

    }

    ans = min(ans, mp);

  }

  

  cout << ans << endl;

}



int main() {

  cin.tie(nullptr);

  ios::sync_with_stdio(false);

  cout << fixed << setprecision(12);

  solve();

  return 0;

}