#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,aa,bb,cc,sum;
ll l[8];
ll kado(ll a,ll b,ll c,ll i){
  if(i==n&&(a==0||b==0||c==0)) return 10000000000;
  if(i==n) return abs(a-aa)+abs(b-bb)+abs(c-cc)-30;
  ll sum1=kado(a+l[i],b,c,i+1)+10;
  ll sum2=kado(a,b+l[i],c,i+1)+10;
  ll sum3=kado(a,b,c+l[i],i+1)+10;
  ll sum4=kado(a,b,c,i+1);
  sum=min({sum1,sum2,sum3,sum4});
  return sum;
}
int main(){
  cin >>n>>aa>>bb>>cc;
  for(ll i=0;i<n;i++) cin>>l[i];
  cout <<kado(0,0,0,0)<<endl;
}
