#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  int N;
  vector<int> num(3), memo(3);
  cin >> N >> num.at(0) >> num.at(1) >> num.at(2);
  vector<int> l(N), len(N);
  for (int i = 0; i < (int)(N); i++) {
    cin >> l.at(i);
  }
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int ans = 5000;
  int count = 0;
  for (int i = 0; i < (int)(N); i++) {
    for (int j = 0; j < (int)(N); j++) {
      if (i == j) {
        continue;
      }
      for (int k = 0; k < (int)(N); k++) {
        if ((i == k) || (j == k)) {
          continue;
        }
        memo.at(0) = i;
        memo.at(1) = j;
        memo.at(2) = k;
        for (int n = 0; n < (int)(N); n++) {
          len.at(n) = l.at(n);
        }
        for (int n = 0; n < (int)(3); n++) {
          int c = len.at(memo.at(n));
          for (int m = 0; m < (int)(N); m++) {
            if ((m == i) || (m == j) || (m == k)) {
              continue;
            } else if ((10 < len.at(m)) &&
                       (len.at(m) < 9 + abs(num.at(n) - c))) {
              c += len.at(m);
              len.at(m) = 0;
              count += 10;
            }
          }
          count += abs(num.at(n) - c);
        }
        if (ans > count) {
          ans = count;
        }
        count = 0;
      }
    }
  }
  cout << ans << endl;
}
