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

int main(){
  int i,N,K=1,k,A[3],a[3],ans=10000,st,now;
  cin>>N>>A[0]>>A[1]>>A[2];
  vector<int> v(N);
  rep(i,N){cin>>v[i];K*=4;}
  while(K--){
    k=K;
    now=N*10-30;
    rep(i,3)a[i]=0;
    rep(i,N){
      st=k%4;
      k/=4;
      if(st==0){now-=10;continue;}
      a[st-1]+=v[i];
    }
    rep(i,3){
      if(a[i]==0)now=100000;
      now+=abs(a[i]-A[i]);
    }
    if(ans>now)ans=now;
  }
  cout<<ans<<endl;
  return 0;
}