#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  int l[8] = {};
  for (int i = 0; i < N; i++) cin >> l[i];
  int d[N];
  int ans = 100000000;
  for (int i = 0; i < 4; i++) {
    d[0] = i;
    for (int j = 0; j < 4; j++) {
      d[1] = j;
      for (int k = 0; k < 4; k++) {
        d[2] = k;
        for (int m = 0; m < 4; m++) {
          d[3] = m;
          for (int n = 0; n < 4; n++) {
            d[4] = n;
            for (int o = 0; o < 4; o++) {
              d[5] = o;
              for (int p = 0; p < 4; p++) {
                d[6] = p;
                for (int q = 0; q < 4; q++) {
                  d[7] = q;
                  int a = 0, b = 0, c = 0, interim = 0;
                  for (int z = N - 1; z = 0; z--) {
                    if (d[z] == 0) {
                      a += l[z];
                      interim += 10;
                    } else if (d[z] == 1) {
                      b += l[z];
                      interim += 10;
                    } else if (d[z] == 3) {
                      c += l[z];
                      interim += 10;
                    }
                  }
                  if (a == 0 || b == 0 || c == 0) continue;
                  interim += (abs(A - a) + abs(B - b) + abs(C - c) - 30);
                  if (ans > interim) {
                    ans = interim;
                    cout << ""
                         << "\n";
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
