#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using str = string; using cstr = const str;
using ll = long long; using ull = unsigned long long; using cint = const int; using cll = const ll;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7;
static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


struct DFS {
    struct Param {
        int val;
        int count;
    };
    struct State {
        State(){};
        State(int size) {
            self.params = vector<Param>(size);
        }
        vector<Param> params;
        vi path;
    };
    DFS(int depth, IN(vi) Item, int state_size, int A, int B, int C) {
        self.DEPTH = depth;
        self.Item = Item;
        self.STATE_SIZE = state_size;
        self.st = State(state_size);

        self.ans = INF;
        self.A = A; self.B = B; self.C = C;
    }
    int DEPTH;
    vi Item;
    int STATE_SIZE;
    State st;
    int ans;

    int A, B, C;

    void _dfs(int n, int i, State &st) {
        if (n >= self.DEPTH) {
            int cnt1 = st.params[1].count, cnt2 = st.params[2].count, cnt3 = st.params[3].count;
            if (cnt1 > 0 and cnt2 > 0 and cnt3 > 0) {
                int cost = 10 * (cnt1 - 1) + 10 * (cnt2 - 1) + 10 * (cnt3 - 1) +
                           abs(st.params[1].val - A) + abs(st.params[2].val - B) + abs(st.params[3].val - C);
                ans = min(ans, cost);
            }
            return;
        } else {
            st.params[i].val += Item[n];
            st.params[i].count += 1;
            st.path.push_back(i);
            REP(j, self.STATE_SIZE)
                self._dfs(n + 1, j, self.st);
            st.params[i].val -= Item[n];
            st.params[i].count -= 1;
            st.path.pop_back();
        }
    }
    int dfs(int n = 0) {
        REP(i,self.STATE_SIZE)
            self._dfs(n, i, self.st);
        return self.ans;
    }
};


int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-1");


    int N,A,B,C; cin>>N>>A>>B>>C;
    vi L = vi(N); REP(i,N) cin>>L[i];

    var search = DFS(N, L, 4, A, B, C);
    int ans = search.dfs(0);

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256