#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int n, a, b, c;

struct State {
  std::vector<int> bamboo;
  int mp;
  State(void) {
    bamboo.resize(n);
    mp = 0;
  }
};
std::unordered_set<std::vector<int>> checked_list;
std::queue<State> q;
int64_t result = 8000;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  cin >> n >> a >> b >> c;
  State origin_state;
  for (int i = 0; i < n; i++) {
    cin >> origin_state.bamboo[i];
  }
  checked_list.insert(origin_state.bamboo);
  q.push(origin_state);
  while (!q.empty()) {
    State target = q.front();
    q.pop();
    if (target.mp >= result) {
      continue;
    }
    bool check_a = false, check_b = false, check_c = false;
    for (int i = 0; i < n; i++) {
      if (target.bamboo[i] == a) {
        check_a = true;
      } else if (target.bamboo[i] == b) {
        check_b = true;
      } else if (target.bamboo[i] == c) {
        check_c = true;
      }
    }
    if (check_a && check_b && check_c) {
      if (result > target.mp) {
        result = target.mp;
      }
      continue;
    }
    for (int i = 0; i < n; i++) {
      State new_state = target;
      if (new_state.bamboo[i] > 0 && new_state.bamboo[i] + 1 <= 1000) {
        new_state.bamboo[i]++;
        if (checked_list.find(new_state.bamboo) != checked_list.end()) {
          new_state.mp++;
          q.push(new_state);
          checked_list.insert(new_state.bamboo);
        }
      }
    }
    for (int i = 0; i < n; i++) {
      State new_state = target;
      if (new_state.bamboo[i] - 1 >= 0) {
        new_state.bamboo[i]--;
        if (checked_list.find(new_state.bamboo) != checked_list.end()) {
          new_state.mp++;
          q.push(new_state);
          checked_list.insert(new_state.bamboo);
        }
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        State new_state = target;
        if (new_state.bamboo[i] > 0 && new_state.bamboo[j] > 0) {
          new_state.bamboo[i] += new_state.bamboo[j];
          new_state.bamboo[j] = 0;
          if (checked_list.find(new_state.bamboo) != checked_list.end()) {
            new_state.mp += 10;
            q.push(new_state);
            checked_list.insert(new_state.bamboo);
          }
        }
      }
    }
  }
  cout << result << endl;

  return 0;
}
