// Slower C++ solution:
#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 PI = 3.1415926535897932;   // acos(-1)

constexpr double EPS = 1e-9;

constexpr int INF = 1001001001;

constexpr int mod = 1000000007;

// constexpr int mod = 998244353;



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

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



int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int n;

    vector<int> foo(3);

    cin >> n >> foo[0] >> foo[1] >> foo[2];

    vector<int> l(n);

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



    int limit = 1;

    for(int i = 0; i < n; ++i)  limit *= 4;

    ll ans = 1e+15;

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

        vector<vector<int>> use(4);

        int hoge = bit;

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

            int id = hoge % 4;

            use[id].push_back(i);

            hoge /= 4;

        }

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

        

        ll cost = 0;

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

            int sz = use[i].size();

            cost += 10 * (sz - 1);

            int LenSum = 0;

            for(int j = 0; j < sz; ++j) LenSum += l[use[i][j]];

            cost += abs(LenSum - foo[i]);

        }

        chmin(ans, cost);

    }



    cout << ans << endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.2407603310889124x):
#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;

}