#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int64_t infi = 1147483600;
const long long infl = 4e18 + 5;
const char EOL = '\n';
const long long MOD = 998244353;
template <typename T>
bool carry3(vector<T>& L) {
  bool carry = true;
  for (auto& l : L) {
    if (carry) {
      carry = false;
      ++l;
      if (l >= 3) {
        carry = true;
        l = 0;
      }
    }
  }
  return carry;
}
int main() {
  long long n;
  vector<long long> E(3);
  cin >> n >> E[0] >> E[1] >> E[2];
  long long combine = (n - 3) * 10;
  vector<long long> L(n);
  for (auto& l : L) {
    cin >> l;
  }
  vector<int> Ord(n, 0);
  long long res = 4e18 + 5;
  while (!carry3(Ord)) {
    long long cur = 0;
    vector<long long> T(3, 0);
    vector<long long> nth(3, 0);
    vector<long long> mins(3, 1e9);
    for (long long i = 0; i < n; ++i) {
      if (T[Ord[i]] >= E[Ord[i]]) continue;
      T[Ord[i]] += L[i];
      mins[Ord[i]] =
          min(mins[Ord[i]], 10 * nth[Ord[i]] + abs(E[Ord[i]] - T[Ord[i]]));
      ++nth[Ord[i]];
    }
    for (auto& m : mins) {
      cur += m;
    }
    res = min(res, cur);
  }
  cout << res << endl;
}
