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

int n, a, b, c;
vector<int> len(8);

int dfs(int i, int x, int y, int z) {
    if(i == n){
        if(min(x, min(y, z))>0) return abs(a - x) + abs(b - y) + abs(c - z) - 30;
        else return 1e5;
    }

    int ret0 = dfs(i + 1, x, y, z);
    int ret1 = dfs(i + 1, x + len[i], y, z) + 10;
    int ret2 = dfs(i + 1, x, y + len[i], z) + 10;
    int ret3 = dfs(i + 1, x, y, z + len[i]) + 10;

    return min(min(ret0, ret1), min(ret2, ret3));
}

int main() {
    cin >> n >> a >> b >> c;

    for (int i = 0; i < n; i++) cin >> len[i];
    cout << dfs(0, 0, 0, 0) << endl;

    return 0;
}