#include <bits/stdc++.h>
using namespace std;

int n, A, B, C, l[9], INF = 1e9;

int rec(int i, int a, int b, int c){
    if (i == n){
        if (!a || !b || !c) return INF;
        return abs(a - A) + abs(b - B) + abs(c - C);
    }
    return min({rec(i + 1, a, b, c), rec(i + 1, a + l[i], b, c) + (a ? 10 : 0), rec(i + 1, a, b + l[i], c) + (b ? 10 : 0), rec(i + 1, a, b, c + l[i]) + (c ? 10 : 0)});
}

int main(){
    cin >> n >> A >> B >> C;
    for (int i = 0; i < n; i++) cin >> l[i];
    cout << rec(0, 0, 0, 0) << endl;
}