#include <bits/stdc++.h>
using namespace std;
int l[9];
int n, a, b, c;
int idx;
int min_diff = INT_MAX;
int size_sum;
bool visited[9];
void solution(int sum[], int to_pick[]) {
  if (idx == 3) {
    int tmp[3] = {a, b, c};
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          int diff = abs(tmp[0] - sum[i]) + abs(tmp[1] - sum[j]) +
                     abs(tmp[2] - sum[k]);
          diff += max(size_sum - 3, 0) * 10;
          if (diff < min_diff) {
            min_diff = diff;
          }
        }
      }
    }
    return;
  }
  if (to_pick[idx] == 0) {
    idx++;
    solution(sum, to_pick);
    idx--;
    return;
  }
  for (int i = 0; i < n; i++) {
    if (!visited[i]) {
      sum[idx] += l[i];
      visited[i] = true;
      to_pick[idx]--;
      solution(sum, to_pick);
      sum[idx] -= l[i];
      visited[i] = false;
      to_pick[idx]++;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> a >> b >> c;
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        if (i + j + k > n) continue;
        idx = 0;
        int sum[3] = {0, 0, 0};
        int to_pick[3] = {i, j, k};
        size_sum = i + j + k;
        solution(sum, to_pick);
      }
    }
  }
  cout << min_diff << '\n';
  return 0;
}
