#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a < b) gcd(b, a);
  long long r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
long long modinv(long long a, long long mod) {
  long long b = mod, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0) u += mod;
  return u;
}
inline long long mod(long long a, long long m) { return (a % m + m) % m; }
long long extGcd(long long a, long long b, long long &p, long long &q) {
  if (b == 0) {
    p = 1;
    q = 0;
    return a;
  }
  long long d = extGcd(b, a % b, q, p);
  q -= a / b * p;
  return d;
}
pair<long long, long long> ChineseRem(long long b1, long long m1, long long b2,
                                      long long m2) {
  long long p, q;
  long long d = extGcd(m1, m2, p, q);
  if ((b2 - b1) % d != 0) return make_pair(0, -1);
  long long m = m1 * (m2 / d);
  long long tmp = (b2 - b1) / d * p % (m2 / d);
  long long r = mod(b1 + m1 * tmp, m);
  return make_pair(r, m);
}
int n, a, b, c;
int l[10];
int num(int x) {
  int ans = 0;
  while (x > 1) {
    ans += x / 2;
    x = (x + 1) / 2;
  }
  return ans;
}
int dfs(int x, int y, int z, int now, int numx, int numy, int numz) {
  if (now == n) {
    if (numx == 0 || numy == 0 || numz == 0) return INT_MAX;
    return abs(x - a) + abs(y - b) + abs(z - c) + num(numx) * 10 +
           num(numy) * 10 + num(numz) * 10;
  } else {
    return min(min(dfs(x + l[now], y, z, now + 1, numx + 1, numy, numz),
                   dfs(x, y + l[now], z, now + 1, numx, numy + 1, numz)),
               min(dfs(x, y, z + l[now], now + 1, numx, numy, numz + 1),
                   dfs(x, y, z, now + 1, numx, numy, numz)));
  }
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> a >> b >> c;
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  cout << dfs(0, 0, 0, 0, 0, 0, 0);
}
