#include <bits/stdc++.h>
using namespace std;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int N, A, B, C;
int L[10];
int mn = 1000000000;
int Com(int n, int a, int b, int c) {
  if (n == N) {
    if (min(a, min(b, c)) == 0)
      return mn = min(mn, 1000000000);
    else
      return mn = min(mn, abs(A - a) + abs(B - b) + abs(C - c));
  }
  int ans = 1000000000;
  ans = min(ans, Com(n + 1, a, b, c));
  ans = min(ans, Com(n + 1, a + 10, b, c) + (a > 0 ? 10 : 0));
  ans = min(ans, Com(n + 1, a, b + 10, c) + (b > 0 ? 10 : 0));
  ans = min(ans, Com(n + 1, a, b, c + 10) + (c > 0 ? 10 : 0));
  return ans;
}
int main() {
  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  int ans = Com(0, 0, 0, 0);
  cout << ans << endl;
}
