#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
using vi=vector<long long>;
using vvi=vector<vector<long long>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000009;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}

int ans=999999999;
vi x(3);
int n;
void dfs(vvi v,int c,int i,vi a){
  if(c!=3)v[c].push_back(a[i]);
  if(i==n-1)dfs(v,3,i+1,a);
  else if(i==n){
    int mp=0;
    rep(j,3){
      int sum=0;
      mp+=(v[j].size()-1)*10;
      rep(k,v[j].size())sum+=v[j][k];
      mp+=abs(sum-x[j]);
    }
    chmin(ans,mp);
  }
  else{
    dfs(v,0,i+1,a);
    dfs(v,1,i+1,a);
    dfs(v,2,i+1,a);
    dfs(v,3,i+1,a);
  }
}
int main(){
  cin>>n;
  vvi v(3);
  rep(i,3)cin>>x[i];
  vi a(n);
  rep(i,n)cin>>a[i];
  dfs(v,3,-1,a);
  cout<<ans<<endl;
}