#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

const int Inf = 1e9 + 7;
int N, A[3];
int l[8];

int solve(int m) {
  int mp = 0;
  int sum[3] = {0, 0, 0};
  rep(i, N) {
    int type = (m >> 2*i) & 0b11;
    if (type == 3) continue;
    if (sum[type]) mp += 10;
    sum[type] += l[i];
  }
  rep(i, 3) {
    mp += abs(A[i] - sum[i]);
    if(!sum[i]) return Inf;
  }
  return mp;
}

int main() {
  cin >> N;
  rep(i, 3) cin >> A[i];
  rep(i, N) cin >> l[i];

  int ans = Inf;
  for (int i = 0; i < (1 << 2*N); ++i) {
    ans = min(ans, solve(i));
  }
  cout << ans << endl;
  return 0;
}