#include <bits/stdc++.h>
using namespace std;
long long sub_mod(long long a, long long b, long long x) {
  long long tmp = (a - b) % x;
  if (tmp < 0) tmp += x;
  return tmp;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
int search(int n, vector<int> nums, vector<int> bamboo) {
  int ans = 0;
  for (int num_i = 0; num_i < nums.size(); num_i++) {
    int nor_min_idx = 0;
    int nor_min_val = (1e9);
    for (int i = 0; i < n; i++) {
      int tmp = abs(nums[num_i] - bamboo[i]);
      if (tmp < nor_min_val) {
        nor_min_val = tmp;
        nor_min_idx = i;
      }
    }
    int plus_min_val = (1e9), plus_min_place = 0, plus_min_bit = 0;
    for (int bin = 1; bin < 1 << n; bin++) {
      int sum = 0;
      int cp_bin = bin;
      int bit_cnt = 0;
      for (int j = 0; j < n; j++) {
        if (cp_bin & 1 == 1) {
          sum += bamboo[j];
          ++bit_cnt;
        }
        cp_bin = cp_bin >> 1;
      }
      if (plus_min_val > abs(nums[num_i] - sum) + (plus_min_bit - 1) * 10) {
        plus_min_val = abs(nums[num_i] - sum);
        plus_min_place = bin;
        plus_min_bit = bit_cnt;
      }
    }
    if (nor_min_val < plus_min_val + (plus_min_bit - 1) * 10) {
      ans += nor_min_val;
      bamboo[nor_min_idx] = -(1e9);
    } else {
      ans += plus_min_val + (plus_min_bit - 1) * 10;
      for (int j = 0; j < n; j++) {
        if (plus_min_place & 1 == 1) bamboo[j] = -(1e9);
        plus_min_place = plus_min_place >> 1;
      }
    }
  }
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  vector<int> nums(3);
  cin >> n;
  for (int i = 0; i < 3; i++) cin >> nums[i];
  vector<int> bamboo(n * 4);
  for (int i = 0; i < n; i++) {
    cin >> bamboo[i];
    for (int j = 0; j < nums.size(); j++) {
      if (nums[j] == bamboo[i]) {
        bamboo.erase(bamboo.begin() + i);
        nums.erase(nums.begin() + j);
      }
    }
  }
  int ans = (1e9);
  ans = min(ans, search(n, nums, bamboo));
  sort((nums).begin(), (nums).end());
  ans = min(ans, search(n, nums, bamboo));
  cout << ans << endl;
}
