#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;
void setfspattern_core(int floor, int number, int degree) {
  if (floor == degree) {
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  } else {
    for (int64_t i = 0; i < (int64_t)(number); i++) {
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor + 1, number, degree);
    }
  }
}
void setfspattern(int number, int degree) {
  int64_t array_num = 1;
  for (int64_t i = 0; i < (int64_t)(degree); i++) {
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num, vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0, number, degree);
}
int main() {
  int n;
  cin >> n;
  vector<int> abc(3);
  for (int64_t i = 0; i < (int64_t)(3); i++) cin >> abc.at(i);
  sort(abc.begin(), abc.end());
  vector<int> l(n);
  for (int64_t i = 0; i < (int64_t)(n); i++) cin >> l.at(i);
  setfspattern(4, n);
  int64_t mincost = 1000000000000000;
  for (int64_t i = 0; i < (int64_t)(fspcnt); i++) {
    vector<bool> exist123(3);
    vector<int> totalabc(3);
    for (int64_t j = 0; j < (int64_t)(n); j++) {
      if (fspattern.at(i).at(j) != 3) {
        exist123.at(fspattern.at(i).at(j)) = true;
      }
    }
    if (exist123.at(0) && exist123.at(1) && exist123.at(2)) {
      for (int64_t j = 0; j < (int64_t)(n); j++) {
        int bb = fspattern.at(i).at(j);
        if (bb != 3) {
          totalabc.at(bb) += l.at(j);
        }
      }
      sort(totalabc.begin(), totalabc.end());
      int64_t cost = 0;
      for (int64_t j = 0; j < (int64_t)(3); j++) {
        cost += abs(totalabc.at(j) - abc.at(j));
      }
      int cnt4 = 0;
      for (int64_t j = 0; j < (int64_t)(n); j++) {
        if (fspattern.at(i).at(j) != 3) {
          cnt4++;
        }
      }
      cost += (cnt4 - 3) * 10;
      mincost = min(mincost, cost);
    }
  }
  cout << mincost << endl;
}
