#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 4e10;
const ll MOD = 1e9 + 7;
ll n;
ll a[8];
ll A, B, C;
ll f(ll now, ll cost, ll aa, ll bb, ll cc) {
  ll ans = inf;
  if (now == n) {
    if (aa != A && aa <= 1) return inf;
    if (bb != B && bb <= 1) return inf;
    if (cc != C && cc <= 1) return inf;
    return cost + abs(A - aa) + abs(B - bb) + abs(C - cc);
  }
  ans = min(ans, f(now + 1, cost, aa, bb, cc));
  ans = min(ans, f(now + 1, cost + (aa == 0 ? 0 : 10), aa + a[now], bb, cc));
  ans = min(ans, f(now + 1, cost + (bb == 0 ? 0 : 10), aa, bb + a[now], cc));
  ans = min(ans, f(now + 1, cost + (cc == 0 ? 0 : 10), aa, bb, cc + a[now]));
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> A >> B >> C;
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << f(0, 0, 0, 0, 0) << endl;
  return 0;
}
