#include <bits/stdc++.h>
using namespace std;
int evaluate_no_merge(const vector<int>& ls, const vector<int>& required) {
  int min_diff = INT_MAX;
  for (int a_pos = 0; a_pos < ls.size(); a_pos++) {
    for (int b_pos = 0; b_pos < ls.size(); b_pos++) {
      for (int c_pos = 0; c_pos < ls.size(); c_pos++) {
        if (a_pos == b_pos) continue;
        if (a_pos == c_pos) continue;
        if (b_pos == c_pos) continue;
        int a_diff = abs(required[0] - ls[a_pos]);
        int b_diff = abs(required[1] - ls[b_pos]);
        int c_diff = abs(required[2] - ls[c_pos]);
        int diff = a_diff + b_diff + c_diff;
        min_diff = min(diff, min_diff);
      }
    }
  }
  return min_diff;
}
int evaluate(const vector<int>& ls, const vector<int>& requried) {
  int no_merge_result = evaluate_no_merge(ls, requried);
  if (ls.size() == 3) return no_merge_result;
  int min_result = no_merge_result;
  for (int i = 0; i < ls.size() - 1; i++) {
    for (int j = i + 1; j < ls.size(); j++) {
      vector<int> new_ls = ls;
      new_ls[i] = new_ls[i] + new_ls[j];
      new_ls.erase(new_ls.begin() + j);
      int new_result = evaluate(new_ls, requried) + 10;
      min_result = min(min_result, new_result);
    }
  }
  return min_result;
}
int main() {
  int n;
  int a, b, c;
  cin >> n >> a >> b >> c;
  vector<int> required(3);
  required[0] = a;
  required[1] = b;
  required[2] = c;
  vector<int> ls(n);
  for (int& l : ls) {
    cin >> l;
  }
  int result = evaluate(ls, required);
  cout << result << endl;
  return 0;
}
