#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  int ans = 1000000000;
  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L[i];
  sort((L).begin(), (L).end());
  do {
    int a = L[0], b = L[1], c = L[2];
    int i = 3, cnt = 0;
    while (i < N) {
      if (abs(C - c) > abs(C - (c + L[i])) && C <= 10) {
        c += L[i];
        cnt += 10;
      } else if (abs(B - b) > abs(B - (b + L[i])) && B <= 10) {
        b += L[i];
        cnt += 10;
      } else if (abs(A - a) > abs(A - (a + L[i])) && A <= 10) {
        a += L[i];
        cnt += 10;
      } else
        break;
      i++;
    }
    ans = min(ans, cnt + abs(A - a) + abs(B - b) + abs(C - c));
  } while (std::next_permutation(L.begin(), L.end()));
  cout << ans << endl;
  return 0;
}
