#include <bits/stdc++.h>
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
const long long MOD = 2019ll;
const long long MAX = 100000001ll;
const int mod = 2019;
struct mint {
  long long x;
  mint(long long x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
mint f(long long n) {
  if (n == 0) return 1;
  mint ans = f(n / 2);
  ans *= ans;
  if (n % 2 == 1) ans *= 2;
  return ans;
}
mint g(long long n, long long x) {
  if (x == 0) return 1;
  mint ans = g(n, x / 2);
  ans *= ans;
  if (x % 2 == 1) ans *= n;
  return ans;
}
mint choose(long long n, long long k) {
  mint x = 1, y = 1;
  for (long long i = 0; i < (k); i++) {
    x *= (n - i);
    y *= (i + 1);
  }
  return x / y;
}
struct BIT {
 private:
  vector<long long> bit;
  long long N;

 public:
  BIT(long long size) {
    N = size;
    bit.resize(N + 1);
  }
  void add(long long a, long long w) {
    for (long long x = a; x <= N; x += x & -x) bit[x] += w;
  }
  int sum(long long a) {
    long long ret = 0;
    for (long long x = a; x > 0; x -= x & -x) ret += bit[x];
    return ret;
  }
};
long long fff(long long n, vector<long long> &v, long long i, long long j,
              long long rl) {
  long long can = 0;
  long long can_i = 0;
  cout << v[0] << endl;
  if (rl == 0) {
    for (long long k = 0; k < (n); k++) {
      if (v[k] * (j - k) > can) {
        can = v[k] * (j - k);
        can_i = k;
      }
    }
    v[can_i] = 0;
    return can;
  } else {
    for (long long k = 0; k < (n); k++) {
      if (v[k] * (k - i) > can) {
        can = v[k] * (k - i);
        can_i = k;
      }
    }
    v[can_i] = 0;
    return can;
  }
}
long long ff(long long x) { return x * (x + 1) / 2; }
long long n, a, b, c;
vector<long long> l;
vector<pair<long long, long long> > ans_A;
vector<pair<long long, long long> > ans_B;
vector<pair<long long, long long> > ans_C;
long long sum(vector<long long> &A) {
  long long ans = 0;
  for (long long i = 0; i < (A.size()); i++) ans += A[i];
  return ans;
}
void dfs(vector<long long> &A, vector<long long> &B, vector<long long> &C,
         long long cnt) {
  if (cnt == n) {
    long long nn = A.size();
    long long S = sum(A);
    ans_A.push_back(make_pair(S, nn));
    nn = B.size();
    S = sum(B);
    ans_B.push_back(make_pair(S, nn));
    nn = C.size();
    S = sum(C);
    ans_C.push_back(make_pair(S, nn));
    return;
  }
  cnt++;
  A.push_back(l[cnt - 1]);
  dfs(A, B, C, cnt);
  A.pop_back();
  B.push_back(l[cnt - 1]);
  dfs(A, B, C, cnt);
  B.pop_back();
  C.push_back(l[cnt - 1]);
  dfs(A, B, C, cnt);
  C.pop_back();
  dfs(A, B, C, cnt);
}
int main() {
  cin >> n >> a >> b >> c;
  l.resize(n);
  for (long long i = 0; i < (n); i++) cin >> l[i];
  vector<long long> A;
  vector<long long> B;
  vector<long long> C;
  dfs(A, B, C, 0);
  long long ans = 100000000000;
  for (long long i = 0; i < (ans_A.size()); i++) {
    chmin(ans, abs(a - ans_A[i].first) + (ans_A[i].second - 1) * 10 +
                   abs(b - ans_B[i].first) + (ans_B[i].second - 1) * 10 +
                   abs(c - ans_C[i].first) + (ans_C[i].second - 1) * 10);
  }
  cout << ans << endl;
}
