#include <bits/stdc++.h>
using namespace std;

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < int(k); i++ )
#define FOR(i, a, b) for(int i = (a); i < int(b); i++)

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define INF (int)INT_MAX
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long L;
typedef unsigned long UL;
typedef long long LL;
typedef unsigned long long ULL;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

int calc(vector<int> &v, int a, int b, int c) {
    int cnt = 1;
    bool p = true;
    int w_a = 0, w_b = 0, w_c = 0;
    int mana = 0;
    REP(i, v.size() - 1) if (v[i] == -1 && v[i + 1] == -1) return INF;
    if (v.back() == -1 || v.front() == -1) return INF;

    REP(i, v.size()) {
        if (v[i] == -1) cnt++, p = true;
        else {
            if (cnt == 1) w_a += v[i];
            else if (cnt == 2) w_b += v[i];
            else if (cnt == 3) w_c += v[i];
            if (!p) mana += 10;
            p = false;
        }
    }
    return mana + abs(w_a - a) + abs(w_b - b) + abs(w_c - c);
}

void solve(__attribute__((unused)) int tc = 0) {
    int n, a, b, c;
    cin >> n >> a >> b >> c;

    vector<int> v;
    REP(_, n) {
        int x;
        cin >> x;
        v.pb(x);
    }
    sort(ALL(v));

    int mini = INF;
    vector<int> q;
    REP(i, n + 1) {
        string bitmask(i, 1);
        bitmask.resize(n, 0);
        sort(ALL(bitmask));
        do {
            vector<int> w(2, -1);
            REP(i, n) if (bitmask[i]) w.pb(v[i]);
            //debug(w, bitmask);
            do {
                int x = min(mini, calc(w, a, b, c));
                if (mini > x) {
                    mini = x;
                    q = w;
                }
                //debug(w, mini);
            } while (next_permutation(ALL(w)));
        } while (next_permutation(ALL(bitmask)));
    }
    debug(q);
    cout << mini << endl;
    return;
}

int main() {
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    /*int TC;
      cin >> TC;
      REP(tc, TC) {
      solve(tc);
      }*/
    solve();
#ifdef TIME
    cout << "Execution time(second) : " << int(clock() * 1000.0 / CLOCKS_PER_SEC) << " ms" << endl;
#endif
}


Measured memory_bytes: 256