#include <bits/stdc++.h>
using namespace std;
void pl(vector<int> &l) {
  l[0]++;
  for (int i = 0; i < l.size() - 1; i++) {
    if (l[i] > 3) {
      l[i] = 0;
      l[i + 1]++;
    }
  }
  return;
}
int d(int a, int b) {
  if (a < b)
    return b - a;
  else
    return a - b;
}
int main() {
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<int> l(n);
  vector<int> ho(n, 0);
  for (int i = 0; i < n; i++) cin >> l[i];
  vector<int> ans(3);
  int rslt, min = 1e9 + 1, cnt;
  while (ho[n - 1] < 4) {
    for (int i = 0; i < 4; i++) ans[i] = 0;
    cnt = 0;
    for (int i = 0; i < n; i++) {
      if (ans[ho[i]] != 0 && i < 3) cnt++;
      ans[ho[i]] += l[i];
    }
    if (ans[0] > 0 && ans[1] > 0 && ans[2] > 0) {
      rslt = d(a, ans[0]) + d(b, ans[1]) + d(c, ans[2]) + cnt * 10;
      if (min > rslt) min = rslt;
    }
    pl(ho);
  }
  cout << min << endl;
  return 0;
}
