#include <bits/stdc++.h>
int MP = 0;
int N, Mark[3];
std::vector<int> L;
bool Ac = false;
bool Bc = false;
bool Cc = false;
struct pair {
  int idx;
  int diff;
};
struct double_pair {
  int idx1;
  int idx2;
  int diff;
};
pair least_diff(std::vector<int> &L, int X) {
  int diff = 10000;
  int idx = 0;
  int i = 0;
  for (auto &&e : L) {
    if (std::abs(X - e) < std::abs(diff)) {
      diff = X - e;
      idx = i;
    }
    i++;
  }
  return pair{idx, diff};
}
double_pair mix_diff(std::vector<int> &L, int X) {
  int diff = 10000;
  int idx1 = 0;
  int idx2 = 0;
  int N = L.size();
  for (int i = 0; i < N - 1; ++i) {
    for (int j = i + 1; j < N; ++j) {
      int temp = X - (L[i] + L[j]);
      if (std::abs(temp) < std::abs(diff)) {
        diff = temp;
        idx1 = i;
        idx2 = j;
      }
    }
  }
  return double_pair{idx1, idx2, diff};
}
void check(int idx) {
  switch (idx) {
    case 0:
      Ac = true;
      break;
    case 1:
      Bc = true;
      break;
    case 2:
      Cc = true;
      break;
  }
}
int main() {
  std::cin >> N >> Mark[0] >> Mark[1] >> Mark[2];
  int temp;
  for (int i = 0; i < N; ++i) {
    std::cin >> temp;
    L.push_back(temp);
  }
  std::sort(L.begin(), L.end());
  for (int i = 0; i < L.size(); i++) {
    if (!Ac && L[i] == Mark[0]) {
      Ac = true;
      L.erase(L.begin() + i);
    }
    if (!Bc && L[i] == Mark[1]) {
      Bc = true;
      L.erase(L.begin() + i);
    }
    if (!Cc && L[i] == Mark[2]) {
      Cc = true;
      L.erase(L.begin() + i);
    }
  }
  for (int i = 0; i < 3; ++i) {
    if (i == 0 && Ac) continue;
    if (i == 1 && Bc) continue;
    if (i == 2 && Cc) continue;
    for (;;) {
      auto as_diff = least_diff(L, Mark[i]);
      auto db_diff = mix_diff(L, Mark[i]);
      if (std::abs(as_diff.diff) < 10 ||
          std::abs(as_diff.diff) < std::abs(db_diff.diff)) {
        if (as_diff.diff > 0) {
          MP += as_diff.diff;
          L.erase(L.begin() + as_diff.idx);
        } else if (as_diff.diff < 0) {
          MP -= as_diff.diff;
          L.erase(L.begin() + as_diff.idx);
        }
        check(i);
        break;
      } else {
        MP += 10;
        if (db_diff.idx1 < db_diff.idx2) {
          L[db_diff.idx1] += L[db_diff.idx2];
          L.erase(L.begin() + db_diff.idx2);
        } else {
          L[db_diff.idx2] += L[db_diff.idx1];
          L.erase(L.begin() + db_diff.idx1);
        }
        if (db_diff.diff == 0) {
          check(i);
          break;
        }
      }
    }
  }
  std::cout << MP << std::endl;
}
