#include <iostream>
#include <vector>

using namespace std;

int N, A, B, C;
int L[9];

int f(int i, int a, int b, int c) {
    if (i > N) {
        if (a < A && b < B && c < C) return abs(a) + abs(b) + abs(c) - 30;
        else return 1 << 30;
    }

    int ret = f(i + 1, a, b, c);
    ret = min(ret, f(i + 1, a - L[i], b, c) + 10);
    ret = min(ret, f(i + 1, a, b - L[i], c) + 10);
    ret = min(ret, f(i + 1, a, b, c - L[i]) + 10);

    return ret;
}

int main() {
    cin >> N >> A >> B >> C;
    for (int i = 1; i <= N; ++i) {
        cin >> L[i];
    }

    cout << f(1, A, B, C) << endl;
}