#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j, k, n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<long long> l(n);
  vector<long long> d(3);
  d[0] = a, d[1] = b, d[2] = c;
  for (i = 0; i < n; i++) cin >> l[i];
  sort(l.begin(), l.end());
  long long ans = 100000000;
  do {
    long long x = 0, sum = 0, ret = 0;
    for (i = 0; i < n; i++) {
      if (x == 3) break;
      sum += l[i];
      if (abs(d[x] - sum) < 10 + abs(d[x] - sum - l[i + 1])) {
        ret += abs(sum - d[x]);
        x++;
        sum = 0;
      } else
        ret += 10;
    }
    ans = min(ans, ret);
  } while (next_permutation(l.begin(), l.end()));
  cout << ans << endl;
  return 0;
}
