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

#include <cmath>

using namespace std;

using ll = long long;

int main(){

    ll N,A,B,C;

    cin >> N >> A >> B >> C;

    int l[8] = {};

    for(int i = 0; i < N; i++) cin >> l[i];

    int d[8];

    ll ans = 10000000000;

    

    for(int i = 0; i < 4; i++){

        d[0] = i;

        for(int j = 0; j < 4; j++){

            d[1] = j;

            for(int k = 0; k < 4; k++){

                d[2] = k;

                for(int m = 0; m < 4; m++){

                    d[3] = m;

                    for(int n = 0; n < 4; n++){

                        d[4] = n;

                        for(int o = 0; o < 4; o++){

                            d[5] = o;

                            for(int p = 0; p < 4; p++){

                                d[6] = p;

                                for(int q = 0; q < 4; q++){

                                    d[7] = q;

                                    ll a = 0,b = 0,c = 0,interim = 0;

                                    for(int z = 0; z < N; z++){

                                        if(d[z] == 0){

                                            a += l[z];

                                            interim += 10;

                                        }

                                        else if(d[z] == 1){

                                            b += l[z];

                                            interim += 10;

                                        }

                                        else if(d[z] == 2){

                                            c += l[z];

                                            interim += 10;

                                        }

                                    }

                                    if(a == 0 || b == 0 || c == 0) continue;

                                    interim += (abs(A-a) + abs(B-b) + abs(C-c) - 30);

                                    if(ans > interim) ans = interim;

                                }

                            }

                        }

                    }

                }

            }

        }

    }

    cout << ans << "\n";

    return 0;

}


// Optimized solution to the same problem (faster):
#include "bits/stdc++.h"

using namespace std;

#define ll long long int

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

#define rrep(i,n) for( int i = n; i >= 0; i-- )

#define REP(i,s,t) for( int i = s; i <= t; i++ )

#define RREP(i,s,t) for( int i = s; i >= t; i-- )

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF 2000000000

#define mod 1000000007

#define INF2 1000000000000000000





int main(void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int N, A[3];

    cin >> N >> A[0] >> A[1] >> A[2];

    int l[8];

    rep(i, N) cin >> l[i];

    int ans = INF;

    int pattern = 1;

    rep(i, N) pattern *= 4;

    rep(bit, pattern) {

        int tmp = bit;

        vector<int> v[3];

        int sum[3] = {};

        rep(i, N) {

            if(tmp % 4 != 3) {

                v[tmp % 4].push_back(l[i]);

                sum[tmp % 4] += l[i];

            }

            tmp /= 4;

        }

        bool ok = true;

        rep(i, 3) if(v[i].size() == 0) ok = false;

        if(!ok) continue;

        int cost = 0;

        rep(i, 3) {

            cost += abs(sum[i] - A[i]);

            cost += (v[i].size() - 1) * 10;

        }

        ans = min(ans, cost);

    }

    cout << ans << endl;





    return 0;

}


// Fastest known solution for this problem: