#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int n, a[10], ans = INF, A, B, C;
int main() {
  cin >> n >> A >> B >> C;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int s = 0; s < (1 << n) * (1 << n); s++) {
    int t[10] = {};
    int cnt = 0;
    int x = s;
    while (x) {
      t[++cnt] = x % 4;
      x /= 4;
    }
    int AA = 0, BB = 0, CC = 0, q = 0, w = 0, e = 0;
    for (int i = 1; i <= cnt; i++) {
      if (t[i] == 1) {
        AA += a[i];
        q++;
      }
      if (t[i] == 2) {
        BB += a[i];
        w++;
      }
      if (t[i] == 3) {
        CC += a[i];
        e++;
      }
    }
    int sum = 0;
    sum += (max(q - 1, 0) + max(w - 1, 0) + max(e - 1, 0)) * 10;
    sum += abs(AA - A) + abs(BB - B) + abs(CC - C);
    ans = min(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
