#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
vector<int> demical(long long n, int k, int l) {
  vector<int> rtn(l);
  for (long long i = 0; i < l; i++) {
    rtn[i] = n % k;
    n /= k;
  }
  return rtn;
}
int n;
vector<int> a(3);
int main() {
  cin >> n;
  for (long long i = 0; i < 3; i++) {
    cin >> a[i];
  }
  vector<int> l(8, 1e6);
  for (long long i = 0; i < n; i++) {
    cin >> l[i];
  }
  int res = INT_MAX;
  long long f = pow(4, 8);
  for (long long i = 0; i < f; i++) {
    int cost = 0;
    vector<int> v(4, 0);
    vector<int> k = demical(i, 4, 8);
    for (long long j = 0; j < k.size(); j++) {
      v[k[j]] += l[j];
      if (k[j] != 3) cost += 10;
    }
    for (long long j = 0; j < v.size(); j++) {
      cost += abs(v[j] - a[j]);
    }
    if (v[0] && v[1] && v[2]) {
      chmin(res, cost);
    }
  }
  cout << res - 30 << endl;
  ;
  return 0;
}
