#include <bits/stdc++.h>
using namespace std;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const long long LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  long long c, b, a, num;
  vector<long long> l(n);
  cin >> c >> b >> a;
  for (int i = 0; i < n; ++i) {
    cin >> l[i];
  }
  long long loop = 1;
  long long pow[9];
  for (int i = 0; i <= n; ++i) {
    pow[i] = loop;
    loop *= 4;
  }
  long long use[8];
  long long len[3];
  long long count[3];
  long long ans = INF;
  for (int i = 0; i < pow[n]; ++i) {
    num = i;
    for (int j = 0; j < 3; ++j) {
      len[j] = 0;
      count[j] = 0;
    }
    for (int j = 7; j >= 0; --j) {
      use[j] = num / pow[j];
      num -= (num / pow[j]) * pow[j];
    }
    long long mp = 0;
    for (int j = 0; j < n; ++j) {
      if (use[j] == 0) {
        count[0]++;
        len[0] += l[j];
      } else if (use[j] == 1) {
        count[1]++;
        len[1] += l[j];
      } else if (use[j] == 2) {
        count[2]++;
        len[2] += l[j];
      }
    }
    if (count[0] == 0 || count[1] == 0 || count[2] == 0) {
      continue;
    } else {
      if (count[0] == 1) {
        mp += abs(len[0] - a);
      } else {
        mp += abs(len[0] - a) + 10 * (count[0] - 1);
      }
      if (count[1] == 1) {
        mp += abs(len[1] - b);
      } else {
        mp += abs(len[1] - b) + 10 * (count[1] - 1);
      }
      if (count[2] == 1) {
        mp += abs(len[2] - c);
      } else {
        mp += abs(len[2] - c) + 10 * (count[2] - 1);
      }
      ans = min(ans, mp);
    }
  }
  cout << ans << endl;
  return 0;
}
