#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  vector<int> m(3);
  cin >> N >> m[0] >> m[1] >> m[2];
  vector<int> take(N);
  for (int i = 0; i < N; i++) {
    cin >> take[i];
  }
  sort(m.begin(), m.end());
  sort(take.begin(), take.end());
  int ret = 0;
  for (int i = 0; i < 3; i++) {
    int min_g = 1000000;
    int min_count = 1000000;
    vector<int> min_take = take;
    for (int k = 0; k < pow(2, N); k++) {
      if (k == 0) continue;
      int g = 0;
      int count = 0;
      vector<int> tmp_take = take;
      for (int j = 0; j < N; j++) {
        if ((k >> j & 1) == 1 && tmp_take[j] > 10) {
          g += tmp_take[j];
          tmp_take[j] = 0;
          count++;
        }
      }
      if (abs(g - m.at(i)) < abs(min_g - m.at(i))) {
        min_count = count;
        min_g = g;
        min_take = tmp_take;
      }
      if (abs(g - m.at(i)) == abs(min_g - m.at(i)) && min_count > count) {
        min_count = count;
        min_g = g;
        min_take = tmp_take;
      }
    }
    if (min_count > 0) ret += (min_count - 1) * 10;
    ret += abs(min_g - m.at(i));
    take = min_take;
  }
  cout << ret << endl;
}
