// Original C++ solution (slower):
#include <cstdio>

#include <iostream>

#include <string>

#include <vector>

#include <sstream>

#include <map>

#include <set>

#include <queue>

#include <algorithm>

#include <cmath>

#include <cstring>

#include <typeinfo>

#include <numeric>

#include <functional>

#include <unordered_map>

#include <bitset>

#include <stack>





using namespace std;

using ll = long long;

using ull = unsigned long long;



const ll INF = 1e16;

const ll MOD = 1e9 + 7;



#define REP(i, n) for(ll i = 0; i < n; i++)











int main() {

    ll n, a, b, c;

    cin >> n >> a >> b >> c;

    vector<ll> l(n);

    REP(i, n){

        cin >> l[i];

    }

    ll m = round(pow(2, n * 3));

    ll ans = INF;

    REP(i, m){

        bool use[3][8] = {}, ok = true, flag[8] = {};

        for(ll j = n * 3 - 1; j >= 0; j--){

            if(i & (1 << j)){

                if(flag[j % n]){

                    ok = false;

                    break;

                }

                use[j / n][j % n] = true;

                flag[j % n] = true;

            }

        }

        if(!ok) continue;

        REP(j, 3){

            bool f = false;

            REP(k, n){

                if(use[j][k]) f = true;

            }

            if(!f) ok = false;

        }

        if(!ok) continue;

        ll sum = 0;

        REP(j, 3){

            ll d = 0, cnt = 0;

            REP(k, n){

                if(use[j][k]){

                    d += l[k];

                    cnt++;

                }

            }

            sum += 10 * (cnt - 1);

            if(j == 0) sum += abs(a - d);

            else if(j == 1) sum += abs(b - d);

            else sum += abs(c - d);

        }

        ans = min(ans, sum);

    }

    cout << ans << endl;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <iostream>

#include <string>

#include <vector>

#include <sstream>

#include <map>

#include <set>

#include <queue>

#include <algorithm>

#include <cmath>

#include <cstring>

#include <typeinfo>

#include <numeric>

#include <functional>

#include <unordered_map>

#include <bitset>

#include <stack>





using namespace std;

using ll = long long;

using ull = unsigned long long;



const ll INF = 1e16;

const ll MOD = 1e9 + 7;



#define REP(i, n) for(ll i = 0; i < n; i++)











int main() {

    ll n, a, b, c;

    cin >> n >> a >> b >> c;

    vector<ll> l(n);

    REP(i, n){

        cin >> l[i];

    }

    ll m = round(pow(4, n));

    ll ans = INF;

    REP(i, m){

        ll aa = 0, bb = 0, cc = 0, idx = 0, cnt[4] = {};

        for(ll j = i; j > 0; j /= 4){

            ll t = j % 4;

            if(t == 1){

                aa += l[idx];

                cnt[1]++;

            }

            else if(t == 2){

                bb += l[idx];

                cnt[2]++;

            }

            else if(t == 3){

                cc += l[idx];

                cnt[3]++;

            }

            idx++;

        }

        if(aa == 0 || bb == 0 || cc == 0) continue;

        ll sum = 0;

        sum += 10 * ((cnt[1] - 1) + (cnt[2] - 1) + (cnt[3] - 1));

        sum += abs(aa - a);

        sum += abs(bb - b);

        sum += abs(cc - c);

        ans = min(ans, sum);

    }

    cout << ans << endl;

}


// Fastest known solution for this problem: