#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> ans_length(3);
  int n;
  cin >> n >> ans_length[0] >> ans_length[1] >> ans_length[2];
  vector<int> ls(n);
  for (auto& l : ls) {
    cin >> l;
  }
  vector<int> tag(n, 0);
  vector<int> length(3, 0);
  int min_mp = 1000000000;
  for (int e = 0; e < (1 << (2 * n)); e++) {
    for (int i = 0; i < n; i++) {
      tag[i] = (e >> (2 * i)) % 4;
    }
    fill(length.begin(), length.end(), 0);
    int mp = 0;
    for (int i = 0; i < n; i++) {
      if (tag[i] <= 2) {
        if (length[tag[i]] == 0) {
          length[tag[i]] = ls[i];
        } else {
          length[tag[i]] += ls[i];
          mp += 10;
        }
      }
    }
    for (int i = 0; i < 3; i++) {
      mp += abs(ans_length[i] - length[i]);
    }
    min_mp = min(min_mp, mp);
  }
  cout << min_mp << endl;
}
