#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;

int makeMP(vector<int> L, int A, int B, int C) {
    // cout << L.size() << endl;
    int use = 0, answer = 0;
    int mpp = 10000;
    if (L.size() == 0) return 10000;
    // cout << L.size() << endl;
    for (int i = 1; i < (1 << L.size()); ++i) {
        int temp = 0;
        if (i & (1 << 0)) temp += L[0];
        if (i & (1 << 1)) temp += L[1];
        if (i & (1 << 2)) temp += L[2];
        if (i & (1 << 3)) temp += L[3];
        if (i & (1 << 4)) temp += L[4];
        if (i & (1 << 5)) temp += L[5];
        if (i & (1 << 6)) temp += L[6];
        if (i & (1 << 7)) temp += L[7];
        int useMp = abs(A - temp) - 10;
        for (int j = 0; j < 8; ++j) {
            if (i & (1 << j)) useMp += 10;
        }
        mpp = min(mpp, useMp);
        if (mpp == useMp) use = i;
    }
    answer += mpp;
    int t = 0;
    for (int i = 0; i < 8; ++i) {
        if (use & (1 << i)) {
            L.erase(L.begin() + i - t);
            ++t;
        }
    }
    mpp = 10000, use = 0;
    if (L.size() == 0) return 10000;
    // cout << L.size() << endl;
    for (int i = 1; i < (1 << L.size()); ++i) {
        int temp = 0;
        if (i & (1 << 0)) temp += L[0];
        if (i & (1 << 1)) temp += L[1];
        if (i & (1 << 2)) temp += L[2];
        if (i & (1 << 3)) temp += L[3];
        if (i & (1 << 4)) temp += L[4];
        if (i & (1 << 5)) temp += L[5];
        if (i & (1 << 6)) temp += L[6];
        if (i & (1 << 7)) temp += L[7];
        int useMp = abs(B - temp) - 10;
        for (int j = 0; j < 8; ++j) {
            if (i & (1 << j)) useMp += 10;
        }
        mpp = min(mpp, useMp);
        if (mpp == useMp) use = i;
    }
    // cout << use << endl;
    answer += mpp;
    t = 0;
    for (int i = 0; i < 8; ++i) {
        if (use & (1 << i)) {
            L.erase(L.begin() + i - t);
            ++t;
        }
    }
    mpp = 10000, use = 0;
    if (L.size() == 0) return 10000;
    // cout << L.size() << endl;
    for (int i = 1; i < (1 << L.size()); ++i) {
        int temp = 0;
        if (i & (1 << 0)) temp += L[0];
        if (i & (1 << 1)) temp += L[1];
        if (i & (1 << 2)) temp += L[2];
        if (i & (1 << 3)) temp += L[3];
        if (i & (1 << 4)) temp += L[4];
        if (i & (1 << 5)) temp += L[5];
        if (i & (1 << 6)) temp += L[6];
        if (i & (1 << 7)) temp += L[7];
        int useMp = abs(C - temp) - 10;
        for (int j = 0; j < 8; ++j) {
            if (i & (1 << j)) useMp += 10;
        }
        mpp = min(mpp, useMp);
        if (mpp == useMp) use = i;
    }
    answer += mpp;
    // cout << use << endl;
    t = 0;
    for (int i = 0; i < 8; ++i) {
        if (use & (1 << i)) {
            L.erase(L.begin() + i - t);
            ++t;
        }
    }
    // cout << answer << endl;
    return answer;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    int A, B, C;
    cin >> N >> A >> B >> C;
    vector<int> M(N);
    for (int i = 0; i < N; ++i) {
        cin >> M[i];
    }
    vector<int> L;
    copy(M.begin(), M.end(), back_inserter(L));
    int answer = makeMP(L, A, B, C);
    L.clear();
    copy(M.begin(), M.end(), back_inserter(L));
    answer = min(answer, makeMP(L, A, C, B));
    L.clear();
    copy(M.begin(), M.end(), back_inserter(L));
    answer = min(answer, makeMP(L, B, A, C));
    L.clear();
    copy(M.begin(), M.end(), back_inserter(L));
    answer = min(answer, makeMP(L, B, C, A));
    L.clear();
    copy(M.begin(), M.end(), back_inserter(L));
    answer = min(answer, makeMP(L, C, A, B));
    L.clear();
    copy(M.begin(), M.end(), back_inserter(L));
    answer = min(answer, makeMP(L, C, B, A));
    cout << answer << endl;
}

Measured memory_bytes: 256