#include <iostream>
using namespace std;

int n,a[4],l[10],m=1e9;

int f(int x){
    int y=x,v[4],w[4],z=0;
    fill(v, v+4, 0);
    fill(w, w+4, -1);
    for(int i=0;i<n;i++){
        v[y%4]+=l[i];
        w[y%4]++;
        y/=4;
    }
    for(int i=1;i<4;i++){
        if(w[i]==-1)return 1e9;
        z+=abs(v[i]-a[i])+w[i]*10;
    }
    return z;
}

int main(void){
    cin>>n>>a[1]>>a[2]>>a[3];
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    for(int i=0;i<(1<<(n*2));i++){
        m=min(m, f(i));
    }
    cout<<m<<endl;
}
