#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
int n, a, b, c;
map<vector<int>, int> mp;
struct State {
  vector<int> l;
  bool has_a = false, has_b = false, has_c = false;
  int point;
  State(vector<int> l, int point = 0) : l(l), point(point) { check(); }
  void check() {
    int ai = -1, bi = -1, ci = -1;
    for (int i = 0; i < l.size(); ++i) {
      if (!has_a && l[i] == a) {
        ai = i;
        has_a = true;
      } else if (!has_b && l[i] == b) {
        bi = i;
        has_b = true;
      } else if (!has_c && l[i] == c) {
        ci = i;
        has_c = true;
      }
    }
    if (ai >= 0) l.erase(l.begin() + ai);
    if (bi >= 0) l.erase(l.begin() + bi);
    if (ci >= 0) l.erase(l.begin() + ci);
  }
  int add(int i, int a) {
    if (l[i] > a) return 0;
    int p = a - l[i];
    l[i] = a;
    point += p;
    check();
    return p;
  }
  int dec(int i, int a) {
    if (l[i] < a || l[i] < 2) return 0;
    int p = l[i] - a;
    l[i] = a;
    point += p;
    check();
    return p;
  }
  int composite(int i, int j) {
    l[i] += l[j];
    l.erase(l.begin() + j);
    point += 10;
    check();
    return 10;
  }
  bool finished() {
    for (int lx : l) {
      if (!has_a && lx == a)
        has_a = true;
      else if (!has_b && lx == b)
        has_b = true;
      else if (!has_c && lx == c)
        has_c = true;
    }
    return has_a && has_b && has_c;
  }
  bool operator>(const State& s) const { return point > s.point; }
};
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> a >> b >> c;
  vector<int> l(n);
  for (int i = 0; i < n; ++i) cin >> l[i];
  priority_queue<State, vector<State>, greater<State> > que;
  que.push(State(l, 0));
  while (!que.empty()) {
    State s = que.top();
    que.pop();
    int m = s.l.size();
    int aim = 0;
    if (!s.has_a)
      aim = a;
    else if (!s.has_b)
      aim = b;
    else
      aim = c;
    if (s.finished()) {
      cout << s.point << "\n";
      return 0;
    }
    for (int i = 0; i < m; ++i) {
      State t = s;
      if (t.l[i] > aim) continue;
      t.add(i, aim);
      if (!mp[t.l] || mp[t.l] > t.point) {
        que.push(t);
        mp[t.l] = t.point;
      }
    }
    for (int i = 0; i < m; ++i) {
      State t = s;
      if (t.l[i] < aim || t.l[i] == 1) continue;
      t.dec(i, aim);
      if (!mp[t.l] || mp[t.l] > t.point) {
        que.push(t);
        mp[t.l] = t.point;
      }
    }
    for (int i = 0; i < m; ++i) {
      for (int j = 0; j < m; ++j) {
        if (i == j) continue;
        State t = s;
        t.composite(i, j);
        if (!mp[t.l] || mp[t.l] > t.point) {
          que.push(t);
          mp[t.l] = t.point;
        }
      }
    }
  }
}
