#include<bits/stdc++.h>
using namespace std;
#define int int64_t 
const int INF = 1e9;
const int MOD = INF+7;
const int LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)

int N,A,B,C;
vector<int> L;
int dfs(int cnt,int a,int b,int c){
    if(cnt == N) return abs(a - A) + abs(b - B) + abs(c - C) + (min(a,b,c) > 0 ? -30 : INF);

    int non = dfs(cnt+1, a, b, c); 
    int use_A = dfs(cnt+1, a+L[cnt], b, c) + 10;
    int use_B = dfs(cnt+1, a, b+L[cnt], c) + 10;
    int use_C = dfs(cnt+1, a, b, c+L[cnt]) + 10;
    return min({non,use_A,use_B,use_C});
}

signed main(){
    int N,A,B,C;
    cin >> N >> A >> B >> C;
    L.resize(N);
    cout << dfs(0,0,0,0) << endl;
}
