#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
const long long MOD = 1000000007LL;
int main() {
  long long n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<long long> l(n);
  for (int i = 0; i < (int)(n); i++) cin >> l[i];
  long long MIN = INF;
  long long big = std::pow(4, n);
  for (long long bit = 0; bit < big; bit++) {
    long long k = bit;
    long long sumA = 0, sumB = 0, sumC = 0, countA = 0, countB = 0, countC = 0;
    for (int i = n - 1; i >= 0; i--) {
      long long part = std::pow(4, i);
      if (k / part == 0) {
        countA++;
        sumA += l[i];
      }
      if (k / part == 1) {
        countB++;
        sumB += l[i];
      }
      if (k / part == 2) {
        countC++;
        sumC += l[i];
      }
      k %= part;
    }
    MIN = min(MIN, (countA + countB + countC - 3) * 10 + abs(sumA - a) +
                       abs(sumB - b) + abs(sumC - c));
  }
  cout << MIN << endl;
}
