#include <bits/stdc++.h>
using namespace std;

int N,A,B,C;
vector<int> l(8);
int ans = 1e9;

void dfs(int a, int b, int c, int d, int i){
  if(i == N){
    if(a && b && c){
      int m = i-d-3;
      int res = abs(a-A) + abs(b-B) + abs(c-C) + 10*m;
      ans = min(ans,res);
    }
    return;
  }
  dfs(a+l[i],b,c,d,i+1);
  dfs(a,b+l[i],c,d,i+1);
  dfs(a,b,c+l[i],d,i+1);
  dfs(a,b,c,d+1,i+1);
}

int main(){
  cin>>N>>A>>B>>C;
  for(int i=0;i<N;i++) cin>>l[i];
  dfs(0,0,0,0,0);
  cout<<ans<<endl;
  return 0;
}
