/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//bamboo_remain.at(i).at(j) = k:使わない竹のうち、j本目を、
//k = 0:使わない k = 1:Aのために合成 k = 2:Bのために合成 k = 3:Cのために合成
vector<vector<int>> bamboo_remain; 

void fact_4(int N,vector<int> &now){
    /*for(int V : now) cout << V << " ";
    cout << endl;*/
    if(now.size() >= N){
        bamboo_remain.push_back(now);
        return;
    }
    for(int i = 0;i<4;i++){
        now.push_back(i);
        fact_4(N,now);
        now.pop_back();
    }
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int N;cin >> N;
    vector<int> target(3);
    for(int i = 0;i<3;i++) cin >> target.at(i);
    vector<int> bamboo(N);
    for(int i = 0;i<N;i++) cin >> bamboo.at(i);
    //A,B,Cにする竹を選んで並べる NC3*3!
    //残った竹をどうするか考える 使わない/Aと合成/Bと合成/Cと合成 4^(N-3)
    vector<int> reset = {};
    fact_4(N-3,reset);

    /*for(int i = 0;i<bamboo_remain.size();i++){
        for(int j = 0;j<bamboo_remain.at(i).size();j++){
            cout << bamboo_remain.at(i).at(j) << " ";
        }
        cout << endl;
    }*/

    int ans = 100100100;
    for(int i = 0;i<(1<<N);i++){
        //どの竹をA,B,Cにするかを全探索
        bitset<9> BIT(i);
        if(BIT.count() != 3) continue;
        vector<int> makeThisTarget;
        vector<int> others;
        for(int j = 0;j<N;j++){
            if(BIT.test(j)) makeThisTarget.push_back(bamboo.at(j));
            else others.push_back(bamboo.at(j));
        }
        sort(makeThisTarget.begin(),makeThisTarget.end());
        
        do{
            //どの竹をA,B,Cのどれにするか決めて、それ以外をどの竹に使うかを全探索する
            int nowA = makeThisTarget.at(0),nowB = makeThisTarget.at(1),nowC = makeThisTarget.at(2);
            int cost = 0;
            for(int j = 0;j<bamboo_remain.size();j++){
                cost = 0;
                nowA = makeThisTarget.at(0),nowB = makeThisTarget.at(1),nowC = makeThisTarget.at(2);
                for(int k = 0;k<bamboo_remain.at(j).size();k++){
                    if(bamboo_remain.at(j).at(k) == 1){
                        cost += 10;
                        nowA += others.at(k);
                    }
                    if(bamboo_remain.at(j).at(k) == 2){
                        cost += 10;
                        nowB += others.at(k);
                    }
                    if(bamboo_remain.at(j).at(k) == 3){
                        cost += 10;
                        nowC += others.at(k);
                    }
                }
                cost += abs(target.at(0)-nowA)+abs(target.at(1)-nowB)+abs(target.at(2)-nowC);
                ans = min(ans,cost);
                /*if(cost <= 52){
                    for(int k = 0;k<3;k++)cout << makeThisTarget.at(k) << " ";
                    cout << nowA << " " << nowB << " " << nowC << endl;
                }*/
                /*for(int j = 0;j<3;j++) cout << makeThisTarget.at(j) << " ";
                cout << "NOW " << nowA << " " << nowB << " " << nowC << " "; 
                cout << cost << endl;*/
            }

        }while(next_permutation(makeThisTarget.begin(),makeThisTarget.end()));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616