#include <iostream>
#include <stack>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <numeric>
#include <vector>
using namespace std;
#define endl "\n"
typedef long long Int;
Int N,A,B,C,l[8];

Int dfs(Int cur,Int a,Int b,Int c){
    if(cur==N){
        if(min({a,b,c})>0)return abs(a-A)+abs(b-B)+abs(c-C)-30;
        return 1000000000;
    }
    return min({dfs(cur+1,a,b,c),dfs(cur+1,a+l[cur],b,c)+10,dfs(cur+1,a,b+l[cur],c)+10,dfs(cur+1,a,b,c+l[cur])+10});
}
int main() {
    cin>>N>>A>>B>>C;
    for(int i=0;i<N;i++){
        cin>>l[i];
    }
    cout<<dfs(0,0,0,0)<<endl;
    return 0;
}