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

#include <vector>

#include <algorithm>

#include <cmath>

#include <queue>

#include <string>

#include <map>

#include <set>

#include <tuple>

#include <deque>

#include <numeric>

#include <bitset>

#include <iomanip>

#include <cassert>

#include <chrono>

#include <random>

#include <limits>

#include <iterator>

#include <functional>

#include <sstream>

using namespace std;



typedef long long ll;

typedef pair<int, int> P;

typedef pair<int, double> Pid;

typedef pair<double, int> Pdi;

typedef pair<ll, int> Pl;

const double PI = 3.1415926535897932;   // acos(-1)

const double EPS = 1e-15;

const int INF = 1001001001;

const ll mod = 1e+9 + 7;



#define chmax(x, y) x = max(x, y)

#define chmin(x, y) x = min(x, y)

#define chadd(x, y) x = (x + y) % mod



int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int n;

    cin >> n;

    vector<ll> len(5, -1);

    for(int i = 1; i < 4; ++i)  cin >> len[i];

    vector<ll> l(n);

    int limit = 1;

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

        cin >> l[i];

        limit *= 4;

    }



    ll res = 1e+15;

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

        int foo = i;

        int id = 0;

        vector<vector<ll>> hoge(4);

        while(foo > 0){

            hoge[foo % 4].push_back(l[id++]);

            foo /= 4;

        }

        if(hoge[1].size() == 0 || hoge[2].size() == 0 || hoge[3].size() == 0)   continue;

        

        ll score = 0;

        for(int s = 1; s < 4; ++s){

            ll sum = accumulate(hoge[s].begin(), hoge[s].end(), 0ll);

            score += 10ll * (hoge[s].size() - 1);

            score += abs(sum - len[s]);

        }

        chmin(res, score);

    }

    cout << res << endl;

}

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

#include <vector>

#include <algorithm>

#include <cmath>

#include <queue>

#include <string>

#include <map>

#include <set>

#include <stack>

#include <tuple>

#include <deque>

#include <numeric>

#include <bitset>

#include <iomanip>

#include <cassert>

#include <chrono>

#include <random>

#include <limits>

#include <iterator>

#include <functional>

#include <sstream>

#include <complex>

using namespace std;



typedef long long ll;

typedef uint64_t ull;

typedef pair<int, int> P;

constexpr double EPS = 1e-9;

constexpr int INF = 1001001001;

constexpr int mod = 1000000007;

// constexpr int mod = 998244353;



template<class T>

inline bool chmax(T& x, T y){

    if(x < y){

        x = y;

        return true;

    }

    return false;

}

template<class T>

inline bool chmin(T& x, T y){

    if(x > y){

        x = y;

        return true;

    }

    return false;

}



int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int n;

    cin >> n;

    vector<int> len(3);

    for(int i = 0; i < 3; ++i)  cin >> len[i];

    vector<int> l(n);

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

    vector<vector<int>> st(3);

    auto dfs = [&](auto&& self, int N = 0) -> int{

        if(N == n){

            if(!st[0].size() || !st[1].size() || !st[2].size()) return INF;

            int res = 0;

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

                int S = accumulate(st[i].begin(), st[i].end(), 0);

                res += 10 * (st[i].size() - 1);

                res += abs(S - len[i]);

            }

            return res;

        }

        int res = INF;

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

            st[i].push_back(l[N]);

            chmin(res, self(self, N + 1));

            st[i].pop_back();

        }

        chmin(res, self(self, N + 1));

        return res;

    };

    cout << dfs(dfs) << endl;

}

// Fastest known solution for this problem: