#include <bits/stdc++.h>
using namespace std;
int br[10], ar[10], a, b, c, n;
int f() {
  int la = 0, lb = 0, lc = 0, sum = 0;
  for (int i = 0; i < n; ++i) {
    if (br[i] == 1) {
      la += ar[i];
      sum += 10;
    } else if (br[i] == 2) {
      lb += ar[i];
      sum += 10;
    } else if (br[i] == 3) {
      lc += ar[i];
      sum += 10;
    }
  }
  return abs(la - a) + abs(lb - b) + abs(lc - c) + sum - 30;
}
int main() {
  cin >> n >> a >> b >> c;
  for (int i = 0; i < n; ++i) cin >> ar[i];
  int mn = 999999999;
  while (br[9] != 1) {
    br[0] += 1;
    for (int i = 1; i < 10; ++i) br[i] += br[i - 1] / 4, br[i - 1] %= 4;
    mn = min(mn, f());
  }
  cout << mn << endl;
  return 0;
}
