#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int N,A,B,C,m=100000000;
int S[3],cnt[3];
int L[8];

void dfs(int i){
    if(i==N){
        if(cnt[0]>0 && cnt[1]>0 && cnt[2]>0){
            m = min(m,10*(cnt[0]+cnt[1]+cnt[2]-3)+abs(A-S[0])+abs(B-S[1])+abs(C-S[2]));
        }
        return;
    }
    rep(j,3){
        S[j] +=L[i];cnt[j]++;
        dfs(i+1);
        S[j] -=L[i];cnt[j]--;
    }
    dfs(i+1);
    return;
}



int main(void){
    cin >> N >> A >> B >>C;
    rep(i,N)cin >> L[i];
    dfs(0);
    cout << m << endl;
}
