#include <bits/stdc++.h>
using namespace std;
vector<int> takes;
map<int, int> synth_memo{{0, 0}};
map<int, int> synth_memo_select{{0, 0}};
tuple<int, int> synth(int diff, int select_takes, bool is_initial) {
  if (synth_memo.count(diff)) {
    return {synth_memo[diff], synth_memo_select[diff]};
  } else if (diff < 0) {
    synth_memo[diff] = -diff;
    synth_memo_select[diff] = select_takes;
    return {synth_memo[diff], synth_memo_select[diff]};
  } else {
    if (!is_initial && ((diff <= 10))) {
      synth_memo[diff] = diff;
      synth_memo_select[diff] = select_takes;
      return {synth_memo[diff], synth_memo_select[diff]};
    }
    int min_index = -1;
    int min_mp = INT_MAX;
    int min_mask = 0;
    int index = 0;
    for (const auto& t : takes) {
      if (select_takes & (1 << index)) {
        index++;
        continue;
      }
      int dst_diff = diff - t;
      auto x = synth(dst_diff, select_takes | (1 << index), false);
      auto mp = get<0>(x);
      auto mask = get<1>(x);
      if (!is_initial) {
        mp += 10;
      }
      if (mp < min_mp) {
        min_index = index;
        min_mp = mp;
        min_mask = mask;
      }
      index++;
    }
    if (min_index != -1) {
      select_takes |= (1 << min_index);
      synth_memo[diff] = min_mp;
      synth_memo_select[diff] = select_takes | min_mask;
      return {synth_memo[diff], synth_memo_select[diff]};
    } else {
      cout << "Not Implemented" << endl;
      exit(1);
    }
  }
}
int get_min_mp(const vector<int>& targets) {
  int result = INT_MAX;
  for (int j = 0; j < targets.size(); ++j) {
    int current_mp = 0;
    int current_mask = 0;
    for (int i = 0; i < targets.size(); ++i) {
      synth_memo.clear();
      synth_memo_select.clear();
      synth_memo[0] = 0;
      synth_memo_select[0] = 0;
      auto index = (j + i) % targets.size();
      auto x = synth(targets[index], current_mask, true);
      current_mp += get<0>(x);
      current_mask = get<1>(x);
    }
    if (result > current_mp) {
      result = current_mp;
    }
  }
  return result;
}
int main(void) {
  int n;
  vector<int> targets(3);
  cin >> n;
  cin >> targets[0];
  cin >> targets[1];
  cin >> targets[2];
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    takes.push_back(x);
  }
  auto x = get_min_mp(targets);
  cout << x << endl;
  return 0;
}
