#include <bits/stdc++.h>
using ll = long long;
using graph = std::vector<std::vector<ll>>;
using namespace std;
int main() {
  int N;
  int A[3];
  cin >> N >> A[0] >> A[1] >> A[2];
  int l[N];
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }
  ll minCost = 1ll << 60;
  for (int p = 0; p < pow(4, N); p++) {
    int tmpP = p;
    int currentId = 0;
    int id[N];
    for (int i = 0; i < N; i++) {
      id[i] = -1;
    }
    while (tmpP != 0) {
      int tmp = tmpP % 4;
      tmpP = (tmpP - tmp) / 4;
      id[currentId] = tmp;
      currentId++;
    }
    int sum[3];
    ll currentCost = 0;
    for (int i = 0; i < 3; i++) {
      sum[i] = 0;
    }
    for (int i = 0; i < N; i++) {
      if (id[i] == 3) {
        continue;
      }
      if (sum[id[i]] > 0) {
        sum[id[i]] += l[i];
        currentCost += 10;
      } else {
        sum[id[i]] += l[i];
      }
    }
    for (int i = 0; i < 3; i++) {
      currentCost += abs(sum[i] - A[i]);
    }
    if (sum[0] == 0 || sum[1] == 0 || sum[2] == 0) {
      continue;
    }
    minCost = min(minCost, currentCost);
  }
  cout << minCost << endl;
}
