#include <bits/stdc++.h>
int main(void) {
  int n;
  scanf("%d", &n);
  std::vector<int> len(n), lenABC(3);
  int cost = 10000000;
  for (int i = 0; i < 3; i++) scanf("%d", &lenABC.at(i));
  for (int i = 0; i < n; i++) scanf("%d", &len.at(i));
  int full_exploration = (int)pow(4, n);
  for (int i = 0; i < full_exploration; i++) {
    int choice = i, index = 0;
    int lenA = 0, lenB = 0, lenC = 0;
    int cur_cost = 0;
    while (choice != 0) {
      if (choice % 4 == 0) {
        if (lenA != 0) cur_cost += 10;
        lenA += len.at(index);
      } else if (choice % 4 == 1) {
        if (lenB != 0) cur_cost += 10;
        lenB += len.at(index);
      } else if (choice % 4 == 2) {
        if (lenC != 0) cur_cost += 10;
        lenC += len.at(index);
      }
      choice /= 4;
      index++;
    }
    if (lenA == 0 || lenB == 0 || lenC == 0) continue;
    cur_cost += abs(lenABC.at(0) - lenA) + abs(lenABC.at(1) - lenB) +
                abs(lenABC.at(2) - lenC);
    if (cost > cur_cost) cost = cur_cost;
  }
  printf("%d\n", cost);
}
