#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, abc[3], tmp;
  vector<int> l;
  int mp = 0;
  bool comp[3];
  int mptmp[3];
  scanf("%d%d%d%d", &n, &abc[0], &abc[1], &abc[2]);
  for (int i = 0; i < n; i++) {
    scanf("%d", &tmp);
    l.push_back(tmp);
  }
  sort(l.begin(), l.end());
  for (int i = 0; i < 3; i++) {
    comp[i] = false;
    auto itr = find(l.begin(), l.end(), abc[i]);
    if (itr != l.end()) {
      l.erase(itr);
      comp[i] = true;
    }
  }
  for (int i = 2; i >= 0; i--) {
    if (comp[i]) continue;
    if (*l.begin() > abc[i]) {
      mp += *l.begin() - abc[i];
      comp[i] = true;
      l.erase(l.begin());
      continue;
    }
  }
  while (!comp[0] || !comp[1] || !comp[2]) {
    for (int i = 2; i >= 0; i--) {
      mptmp[i] = 0;
      if (comp[i]) continue;
      int min = 10000, min2 = 10000;
      vector<int>::iterator tmp1, tmp2, tmp3;
      vector<int> ltmp = l;
      while (true) {
        for (auto itr = ltmp.begin(); itr != ltmp.end(); itr++) {
          for (auto itr2 = itr + 1; itr2 != ltmp.end(); itr2++) {
            if (abs(*itr + *itr2 - abc[i]) < min) {
              min = abs(*itr + *itr2 - abc[i]);
              tmp1 = itr;
              tmp2 = itr2;
            }
          }
        }
        for (auto itr = ltmp.begin(); itr != ltmp.end(); itr++) {
          if (min2 > abs(*itr - abc[i])) {
            min2 = abs(*itr - abc[i]);
            tmp3 = itr;
          }
        }
        if (min + 10 >= min2) {
          mptmp[i] += min2;
          ltmp.erase(tmp3);
          break;
        }
        mptmp[i] += 10;
        tmp = *tmp1 + *tmp2;
        ltmp.erase(tmp1);
        ltmp.erase(tmp2);
        ltmp.push_back(tmp);
        sort(ltmp.begin(), ltmp.end());
      }
    }
    int tmp4;
    for (int i = 2; i >= 0; i--) {
      int min = 100000;
      if (!comp[i] && min > mptmp[i]) {
        min = mptmp[i];
        tmp4 = i;
      }
    }
    while (true) {
      int min = 10000, min2 = 10000;
      vector<int>::iterator tmp1, tmp2, tmp3;
      for (auto itr = l.begin(); itr != l.end(); itr++) {
        for (auto itr2 = itr + 1; itr2 != l.end(); itr2++) {
          if (abs(*itr + *itr2 - abc[tmp4]) < min) {
            min = abs(*itr + *itr2 - abc[tmp4]);
            tmp1 = itr;
            tmp2 = itr2;
          }
        }
      }
      for (auto itr = l.begin(); itr != l.end(); itr++) {
        if (min2 > abs(*itr - abc[tmp4])) {
          min2 = abs(*itr - abc[tmp4]);
          tmp3 = itr;
        }
      }
      if (min + 10 >= min2) {
        mp += min2;
        comp[tmp4] = true;
        l.erase(tmp3);
        break;
      }
      mp += 10;
      tmp = *tmp1 + *tmp2;
      l.erase(tmp1);
      l.erase(tmp2);
      l.push_back(tmp);
      sort(l.begin(), l.end());
    }
  }
  printf("%d\n", mp);
  return 0;
}
