#include <bits/stdc++.h>

using namespace std;

int n,A,B,C;
int l[8];

int dfs(int cnt,int a,int b,int c){
    if(cnt==n){
        if(min({a,b,c})>0)
            return abs(a-A)+abs(b-B)+abs(c-C)-30;
        else
            return 10000000;
    }

    int ans1 = dfs(cnt+1,a,b,c);
    int ans2 = dfs(cnt+1,a+l[cnt],b,c)+10;
    int ans3 = dfs(cnt+1,a,b+l[cnt],c)+10;
    int ans4 = dfs(cnt+1,a,b,c+l[cnt])+10;
    return min({ans1,ans2,ans3,ans4});
}

int main(){
    cin>>n>>A>>B>>C;

    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    int ans = dfs(0,0,0,0);
    cout<<ans;
}