#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const int nmax = 8;
ll N, A, B, C;
std::vector<long long> l(N + 1);
bool graph[nmax][nmax];
ll ans = LONG_MAX;
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}
ll mulMod(ll a, ll b) { return (((a % MOD) * (b % MOD)) % MOD); }
ll calc(vector<ll> v) {
  ll cost = 0;
  ll a = 0, b = 0, c = 0;
  for (auto &&i : v) {
    switch (i) {
      case 1:
        if (a != 0) cost += 10;
        a += i;
        break;
      case 2:
        if (b != 0) cost += 10;
        b += i;
        break;
      case 3:
        if (c != 0) cost += 10;
        c += i;
        break;
      default:
        break;
    }
  }
  cost += abs(A - a);
  cost += abs(B - b);
  cost += abs(C - c);
  return cost;
}
int dfs(int n, int na, int a, int nb, int b, int nc, int c) {
  if (n == N) {
    if (na == 0 || nb == 0 || nc == 0) return INT_FAST16_MAX;
    return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (na + nb + nc - 3);
  }
  int tmp1, tmp2, tmp3, tmp4;
  tmp1 = dfs(n + 1, na + 1, a + l[n], nb, b, nc, c);
  tmp2 = dfs(n + 1, na, a, nb + 1, b + l[n], nc, c);
  tmp3 = dfs(n + 1, na, a, nb, b, nc + 1, c + l[n]);
  tmp4 = dfs(n + 1, na, a, nb, b, nc, c);
  int ans;
  ans = min(min(min(tmp1, tmp2), tmp3), tmp4);
  return ans;
}
int main() {
  scanf("%lld", &N);
  scanf("%lld", &A);
  scanf("%lld", &B);
  scanf("%lld", &C);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &l[i]);
  }
  cout << dfs(0, 0, 0, 0, 0, 0, 0) << endl;
  return 0;
}
