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

int n, a, b, c;
vector<int> L(9);
int inf = 10000000;
int dfs(int x, int y, int z, int cnt){
    if (cnt == n){
        if (min({x, y, z}) > 0) return abs(x-a) + abs(y-b) + abs(z-c) - 30;
        return inf;
    }
    int ret1 = dfs(x + L[cnt], y, z, cnt + 1) + 10 ;
    int ret2 = dfs(x, y+ L[cnt], z, cnt + 1) + 10;
    int ret3 = dfs(x, y, z+ L[cnt], cnt + 1) + 10;
    int ret4 = dfs(x, y, z, cnt + 1);

    return min({ret1, ret2, ret3, ret4});
}

int main() {
    cin >> n >> a >> b >> c;
    for (int i = 0; i < n; i++) cin >> L[i];
    cout << dfs(0, 0, 0, 0) << endl;
}

