#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

#define Max 10
int N, A, B, C;
int l[Max];
int dABC[3][Max];
vector<int> ls;

int search_min(int n, int* r, int* l, int exr1, int exr2, int exl1, int exl2) {
    int minval = 10000000;
    rep(i, 3){ 
        rep(j, n) {
            // printf("%d,%d\n", i,j);
            if (i == exr1 || i == exr2) continue;
            if (j == exl1 || j == exl2) continue;
            if (dABC[i][j] < minval) {
                minval = dABC[i][j];
                *r = i;
                *l = j;
            }
        }
    }
    return minval;
}

int search_min(int n) {
    int minval = 1000000;
    rep(a, n) {
        rep(b, n) {
            if (a == b) continue;
            rep(c, n) {
                if (a == c || b == c) continue;
                int score = dABC[0][a]+ dABC[1][b]+dABC[2][c];
                if (score < minval) minval = score;
            }
        }
    }
    return minval;
}

int calc() {
    int n = ls.size();
    rep(i, ls.size()) {
        dABC[0][i] = abs(ls[i] - A);
        dABC[1][i] = abs(ls[i] - B);
        dABC[2][i] = abs(ls[i] - C);
    }
    int ans = search_min(n);

    // rep(i, 3){
    //     rep(j, n) {
    //         printf("%d ",dABC[i][j]);
    //     }
    // }
    // printf("\n");
    // output(ans);

    return ans;
}

int pick2(int max, int count) {
    if (count == max) return calc() + 10 * count;
    int n = ls.size();
    int ans = 10000000;
    rep(t1, n) {
        rep(t2, n) {
            if (t1 == t2) continue;
            int tmp1 = ls[t1];
            int tmp2 = ls[t2];
            if (t1 > t2) {
                ls.erase(ls.begin() + t1);
                ls.erase(ls.begin() + t2);
            } else {
                ls.erase(ls.begin() + t2);
                ls.erase(ls.begin() + t1);
            }
            
            ls.push_back(tmp1 + tmp2);
            ans = min(ans, pick2(max, count+1));
            ls.pop_back();
            if (t1 > t2) {
                ls.insert(ls.begin() + t2, tmp2);
                ls.insert(ls.begin() + t1, tmp1);
            } else {
                ls.insert(ls.begin() + t1, tmp1);
                ls.insert(ls.begin() + t2, tmp2);
            }
        }
    }
    return ans;
}

int main(int argc, const char * argv[]) {
    N = inputValue();
    A = inputValue();
    B = inputValue();
    C = inputValue();
    inputArray(l, N);
    ls.reserve(10);
    rep(i, N) {
        ls.push_back(l[i]);
    }
    
    int ans = calc();
    repd(i, 1, N - 3 + 1){ 
        ans = min(ans, pick2(i, 0));
    }
    output(ans);

    return 0;
}

Measured memory_bytes: 256