#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,c,a,b,ans=1000000000000;
ll l[10];
void solve(ll i,ll sa,ll sb,ll sc,ll fc){
  if(i==n){
    if(sa==0||sb==0||sc==0) return;
    ll tmp = abs(sa-a)+abs(sb-b)+abs(sc-c)+(fc-3)*10;
    ans = min(tmp,ans);
    return;
  }
  solve(i+1,sa+l[i],sb,sc,fc+1);
  solve(i+1,sa,sb+l[i],sc,fc+1);
  solve(i+1,sa,sb,sc+l[i],fc+1);
  solve(i+1,sa,sb,sc,fc);
}
signed main(){
  cin >> n >> a >> b >> c;
  for(int i=0;i<n;i++){
    cin >> l[i];
  }
  solve(0,0,0,0,0);
  cout << ans << endl;
}
