#include <bits/stdc++.h>
using namespace std;
int N, A, B, C, l[8], m = 100000;
void s(int n, int a, int b, int c, int z) {
  if (n == 0) {
    if (!a * b * c) return;
    m = min(m, abs(a - A) + abs(b - B) + abs(c - C) + (z - 3) * 10);
    return;
  }
  n--;
  s(n, a, b, c, z);
  z++;
  s(n, a + l[n], b, c, z);
  s(n, a, b + l[n], c, z);
  s(n, a, b, c + l[n], z);
}
int main(void) {
  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; i++) cin >> l[i];
  s(N, 0, 0, 0, 0);
  cout << m << "\n";
  return 0;
}
