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

int N,A,B,C;
vector<int> ls(8);

int mps(int n,int a,int b, int c){
  if(n==N){
    if (a!=0&&b!=0&&c!=0) return abs(a-A)+abs(b-B)+abs(c-C)-30;
    else return pow(10,9);
  }
  int no_add=mps(n+1,a,b,c);
  int add_a =mps(n+1,a+ls.at(n),b,c)+10;
  int add_b =mps(n+1,a,b+ls.at(n),c)+10;
  int add_c =mps(n+1,a,b,c+ls.at(n))+10;
  return min(min(no_add,add_a),min(add_b,add_c));
}

int main() {
  cin>>N>>A>>B>>C;
  for(int i=0;i<N;i++){cin>>ls.at(i);}
  int min_mps=mps(0,0,0,0);
  cout<<min_mps<<endl;
}