#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long power(long long x, long long m) {
  if (m == 0) return 1;
  if (m == 1) return x;
  if (m % 2 == 0) {
    return power(x * x, m / 2);
  } else {
    return power(x * x, m / 2) * x;
  }
}
int main() {
  long long n;
  cin >> n;
  vector<long long> target(3);
  for (long long i = 0; i < (3); i++) cin >> target[i];
  vector<long long> l(n);
  vector<vector<long long> > take(4);
  for (long long i = 0; i < (n); i++) cin >> l[i];
  long long mincost = 1 << 30;
  for (long long i = 0; i < (power(4, n)); i++) {
    long long sumcost = 0;
    long long tmp = i;
    long long m = 0;
    while (power(4, m) <= i) {
      m++;
    }
    m--;
    while (tmp != 0) {
      long long q = i / power(4, m);
      long long r = i % power(4, m);
      take[q % 4].push_back(l[m]);
      tmp = r;
      m--;
    }
    for (long long i = 0; i < (3); i++) {
      if (take[i].size() == 0) {
        sumcost = 1 << 30;
        continue;
      }
      long long takesum = 0;
      for (auto j : take[i]) {
        takesum += j;
      }
      sumcost += (take[i].size() - 1) * 10 + abs(target[i] - takesum);
    }
    mincost = min(mincost, sumcost);
    for (long long i = 0; i < (4); i++) take[i].clear();
  }
  cout << mincost << endl;
}
