#include<iostream>
using namespace std;
int jou(int a) {
  int k = 1;
  for (int i = 0; i < a; i ++) k *= 4;
  return k;
}
int ze(int a) {
  if (a < 0) return -a;
  else return a;
}
int main () {
  int N;
  cin >> N;
  int A, B, C;
  cin >> A >> B >> C;
  int leng[8];
  int ans = 1000000;
  for (int i = 0; i < N; i ++) cin >> leng[i];
  int kai = jou(N);
  for (int i = 0; i < kai i ++) {
    int k = i;
    int al = bl = cl = 0;
    int mp = 0;
    for (int o = 0; o < N; o ++) {
      int j = k % 4;
      switch(j) {
        case 0: break;
        case 1: al ++; mp += 10; break;
        case 2: bl ++; mp += 10; break;
        case 3: cl ++; mp += 10; break;
      }
      k /= 4;
    }
    mp += ze(A - al);
    mp += ze(B - bl);
    mp += ze(C - cl);
    if (mp < ans) ans = mp;
  }
  cout << ans << endl;
}