#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  int l[10];
  for (int i = 0; i < n; i++) cin >> l[i];
  sort(l, l + n);
  int ans = 0x3f3f3f3f;
  do {
    int tmp = 0, sum = l[0], cnt = 0, nn = a;
    for (int i = 1; i < n; i++) {
      if (abs(sum - nn) <= 10 + abs(sum + l[i] - nn)) {
        tmp += abs(sum - nn);
        sum = l[i];
        cnt += 1;
        if (cnt == 1)
          nn = b;
        else if (cnt == 2)
          nn = c;
      } else {
        sum += l[i];
        tmp += 10;
      }
      if (cnt == 3) break;
    }
    if (cnt == 2) {
      tmp += abs(sum - nn);
    }
    ans = min(ans, tmp);
  } while (next_permutation(l, l + n));
  cout << ans << '\n';
  return 0;
}
