#include <bits/stdc++.h>
using namespace std;
bool prime(long long n) {
  for (long long i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return false;
  }
  return n != 1;
}
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x * y / gcd(x, y); }
long long mod_pow(long long x, long long y, long long mod) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    y >>= 1;
  }
  return res;
}
long long kai(long long x) {
  if (x == 0) return 1;
  return (kai(x - 1) * x) % 1000000007;
}
long long comb(long long x, long long y) {
  return kai(x) * mod_pow(kai(x - y), 1000000007 - 2, 1000000007) % 1000000007 *
         mod_pow(kai(y), 1000000007 - 2, 1000000007) % 1000000007;
}
struct edge {
  long long to, cost;
};
long long dx[5] = {0, 1, 0, -1}, dy[5] = {1, 0, -1, 0};
map<long long, long long> factor(long long x) {
  map<long long, long long> res;
  for (long long i = 2; i * i <= x; i++) {
    while (x % i == 0) {
      x /= i;
      res[i]++;
    }
  }
  if (x != 1) res[x]++;
  return res;
}
long long n, t[9];
long long a, b, c;
long long dfs(long long loa, long long lob, long long loc, long long cnta,
              long long cntb, long long cntc, long long al) {
  if (al == n) {
    if (!loa || !lob || !loc) return 5000000000000000000;
    return (loa - 1) * 10 + (lob - 1) * 10 + (loc - 1) * c + abs(cnta - a) +
           abs(cntb - b) + abs(cntc - c);
  }
  return min({dfs(loa + 1, lob, loc, cnta + t[al], cntb, cntc, al + 1),
              dfs(loa, lob + 1, loc, cnta, cntb + t[al], cntc, al + 1),
              dfs(loa, lob, loc + 1, cnta, cntb, cntc + t[al], al + 1),
              dfs(loa, lob, loc, cnta, cntb, cntc, al + 1)});
}
signed main() {
  cin >> n >> a >> b >> c;
  for (long long i = 0; i < n; i++) cin >> t[i];
  cout << dfs(0, 0, 0, 0, 0, 0, 0) << endl;
  getchar();
  getchar();
  return 0;
}
