#include <iostream>
using namespace std;

int N,a,b,c;

void dfs(int now, int sa, int sb, int sc, int na, int nb, int nc) {
    if (now > N) {
        if (na > 0 && nb > 0 && nc > 0) {
            int cost = (na + nb + nc - 3) * 10;
            cost += abs(sa - a) + abs(sb - b) + abs(sc - c);
            ans = min(ans, cost);
        }
        return 0;
    }
    dfs(now + 1, sa, sb, sc, na, nb, nc);
    dfs(now + 1, sa + a[now], sb, sc, na + 1, nb, nc);
    dfs(now + 1, sa, sb + a[now], sc, na, nb + 1, nc);
    dfs(now + 1, sa, sb, sc + a[now], na, nb, nc + 1);
}

int main(){
    cin>>N>>a>>b>>c;
    int a[10];
    for(int i = 1; i <= N; i++)
        cin>>a[i];
    ans=1000000000;
    dfs(1,0,0,0,0,0,0);
    cout<<ans<<endl;
}