#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
int main() {
  int P[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  int l[N];
  for (int i = (0); i < (N); i++) {
    cin >> l[i];
  }
  int ans = 1LL << 9;
  while (1) {
    int sum = 0;
    int a = 0, b = 0, c = 0;
    int a_c = -1, b_c = -1, c_c = -1;
    if (P[N] == 1) {
      break;
    }
    for (int i = (0); i < (N); i++) {
      if (P[i] == 0)
        continue;
      else if (P[i] == 1) {
        a += l[i];
        a_c++;
      } else if (P[i] == 2) {
        b += l[i];
        b_c++;
      } else {
        c += l[i];
        c_c++;
      }
    }
    if (a != 0 && b != 0 && c != 0) {
      int cost = 0;
      cost += abs(A - a) + abs(B - b) + abs(C - c) + 10 * (a_c + b_c + c_c);
      ans = min(cost, ans);
    }
    int next = 1;
    for (int i = (0); i < (N + 1); i++) {
      P[i] += next;
      if (P[i] >= 4) {
        P[i] = 0;
        next = 1;
      } else {
        next = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
