#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c;
  int l[10];
  scanf("%d %d %d %d", &n, &a, &b, &c);
  for (int i = 0; i < n; i++) {
    scanf("%d", l + i);
  }
  std::sort(l, l + n);
  int ans = 1 << 30;
  do {
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        for (int k = j + 1; k <= n; k++) {
          int aa = 0;
          int bb = 0;
          int cc = 0;
          int sum = 0;
          for (int p = 0; p < i; p++) {
            aa += l[p];
          }
          sum += ((aa - a) > 0 ? (aa - a) : -(aa - a)) + (i - 1) * 10;
          for (int p = i; p < j; p++) {
            bb += l[p];
          }
          sum += ((bb - b) > 0 ? (bb - b) : -(bb - b)) + (j - i - 1) * 10;
          for (int p = j; p < k; p++) {
            cc += l[p];
          }
          sum += ((cc - c) > 0 ? (cc - c) : -(cc - c)) + (k - j - 1) * 10;
          ans = ((sum) > (ans) ? (ans) : (sum));
          for (int p = 0; p < n; p++) {
            printf("%d, ", l[p]);
          }
          printf("\n");
          printf("%d, %d, %d\n", i, j, k);
          printf("%d\n", sum);
        }
      }
    }
  } while (std::next_permutation(l, l + n));
  printf("%d\n", ans);
  return 0;
}
