#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
int main(){
  int n;cin>>n;
  vi x(3);
  rep(i,3)cin>>x[i];
  ll ans=inf;
  vi v(n);
  rep(i,n)cin>>v[i];
  rep(i,(1<<n*2)){
    ll k=i;
  	vi num(4);
  	vi sum(4);
    rep(j,n){
      num[(k|0)]++;
      sum[(k|0)]+=v[j];
      k>>=2;
    }
    if(num[1]==0||num[2]==0||num[3]==0)continue;
    ll p=0;
    rep(j,3)p+=(num[j+1]-1)*10;
    rep(j,3)p+=abs(sum[j+1]-x[j]);
    chmin(ans,p);
  }
  cout<<ans<<endl;
}