#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  int l[9], SWI[70000], Atmp = 0, Btmp = 0, Ctmp = 0;
  int cost = 1000000;
  for (int i = 1; i <= N; i++) cin >> l[i];
  for (int i = 0; i < pow(4, N); i++) {
    int rem = i;
    for (int j = N - 1; j >= 0; j--) {
      SWI[j + 1] = rem / (int)pow(4, j);
      rem = rem % (int)pow(4, j);
    }
    int gosei = -3;
    for (int j = 1; j <= N; j++) {
      if (SWI[j] == 0) {
        Atmp += l[j];
        gosei++;
      } else if (SWI[j] == 1) {
        Btmp += l[j];
        gosei++;
      } else if (SWI[j] == 2) {
        Ctmp += l[j];
        gosei++;
      }
      if (gosei >= 0)
        cost = min(cost,
                   abs(Atmp - A) + abs(Btmp - B) + abs(Ctmp - C) + gosei * 10);
    }
    Atmp = 0;
    Btmp = 0;
    Ctmp = 0;
  }
  printf("%d", cost);
}
