#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int n,a,b,c;

struct State {
    vector<int> l;
    bool has_a = false, has_b = false, has_c = false;
    int point;
    State(vector<int> l, int point=0): l(l), point(point) {
        check();
    }

    void check() {
        int ai = -1, bi = -1, ci = -1;
        for(int i=0;i<l.size();++i) {
            if(!has_a && l[i] == a) {
                ai = i;
                has_a = true;
            }
        }
        if(ai >= 0) l.erase(l.begin()+ai);
        for(int i=0;i<l.size();++i) {
            if(!has_b && l[i] == b) {
                bi = i;
                has_b = true;
            }
        }
        if(bi >= 0) l.erase(l.begin()+bi);
        for(int i=0;i<l.size();++i) {
            if(!has_c && l[i] == c) {
                ci = i;
                has_c = true;
            }
        }
        if(ci >= 0) l.erase(l.begin()+ci);
    }

    int add(int i,int a) {
        int p = abs(a - l[i]);
        l[i] = a;
        point += p;
        check();
        return p;
    }

    int composite (int i, int j) {
        l[i] += l[j];
        l.erase(l.begin() + j);
        point += 10;
        check();
        return 10;
    }

    bool finished() {
        for(int lx: l) {
            if(!has_a && lx == a) has_a = true;
            else if(!has_b && lx == b) has_b = true;
            else if(!has_c && lx == c) has_c = true;
        }
        return has_a && has_b && has_c;
    }

    bool operator>(const State& s) const{
        return point > s.point;
    }

    bool operator<(const State& s) const{
        if(l != s.l) return l < s.l;
        if(has_a != s.has_a) return has_a < s.has_a;
        if(has_b != s.has_b) return has_b < s.has_b;
        if(has_c != s.has_c) return has_c < s.has_c;
        return 0;
    }
};

int main() {
    cin >> n >> a >> b >> c;
    vector<int> l(n);
    for(int i=0;i<n;++i) cin >> l[i];


    priority_queue<State, vector<State>, greater<State> > que;
    map<State, int> mp;
    que.push(State(l, 0));
    int ans = INT_MAX;
    while(!que.empty()) {
        State s = que.top(); que.pop();
        if(s.finished()) {
            cout << s.point << "\n";
            return 0;
        }

        int m = s.l.size();

        for(int i=0;i<m;++i) {
            if(!s.has_a) {
                State t = s;
                t.add(i, a);
                if(!mp[t] || mp[t] > t.point) {
                    que.push(t);
                    mp[t] = t.point;
                }
            }
            if(!s.has_b) {
                State t = s;
                t.add(i, b);
                if(!mp[t] || mp[t] > t.point) {
                    que.push(t);
                    mp[t] = t.point;
                }
            }
            if(!s.has_c) {
                State t = s;
                t.add(i, c);
                if(!mp[t] || mp[t] > t.point) {
                    que.push(t);
                    mp[t] = t.point;
                }
            }
        }
        for(int i=0;i<m;++i) {
            for(int j=0;j<m;++j) {
                if(i == j) continue;
                State t = s;
                t.composite(i, j);
                if(!mp[t] || mp[t] > t.point) {
                    que.push(t);
                    mp[t] = t.point;
                }
            }
        }
    }
}


Measured memory_bytes: 32488