#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n, a, b, c, res = LINF;
    cin >> n >> a >> b >> c;

    vector<int> l(n);

    for(auto&& e : l){
        cin >> e;
    }

    for(int bit1 = 1; bit1 < (1 << n); ++bit1){
        if(n - __builtin_popcount(bit1) < 2) continue;
        vector<int> others, sum(3);
        rep(i,n){
            if(bit1 & 1 << i){
                sum[0] += l[i];
            }else{
                others.emplace_back(l[i]);
            }
        }
        int os = others.size();
        for(int bit2 = 1; bit2 < (1 << os); ++bit2){
            if(os - __builtin_popcount(bit2) < 1) continue;
            vector<int> last;
            sum[1] = 0;
            rep(i,os){
                if(bit2 & 1 << i){
                    sum[1] += others[i];
                }else{
                    last.emplace_back(others[i]);
                }
            }
            int ls = last.size();
            for(int bit3 = 1; bit3 < (1 << ls); ++bit3){
                sum[2] = 0;
                rep(i,ls){
                    if(bit3 & 1 << i){
                        sum[2] += last[i];
                    }
                }
                auto lowat = sum;
                /*
                cout << sum[0] << ' ' << sum[1] << ' ' << sum[2] << '\n';
                cout << __builtin_popcount(bit1) << ' ' << os << ' ' << ls << '\n';
                */
                sort(all(lowat));
                int tmp = abs(c - lowat[0]) + abs(b - lowat[1]) + abs(a - lowat[2]);
                tmp += 10 * (__builtin_popcount(bit1) + __builtin_popcount(bit2) + __builtin_popcount(bit3) - 3);
                chmin(res, tmp);
            }
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256