#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<int> data(N), cal(4), count(4);
  for (int i = 0; i < N; i++) cin >> data.at(i);
  int ans = 10000, sub, a;
  for (int i = 0; i < pow(4, N); i++) {
    a = i;
    sub = 0;
    for (int j = 0; j < 4; j++) cal.at(j) = 0, count.at(j) = 0;
    for (int j = 0; j < N; j++) {
      cal.at(a % 4) += data.at(j);
      count.at(a % 4)++;
      if (count.at(a % 4) > 1 && count.at(a % 4) != 0) sub += 10;
      a /= 4;
    }
    sub += abs(A - cal.at(1)) + abs(B - cal.at(2)) + abs(C - cal.at(3));
    ans = min(ans, sub);
  }
  cout << ans << endl;
  return 0;
}
