#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  int INF = 100000000;
  vector<int> k(8, INF), p(4, 0), q(4, 0);
  for (int i = 0; i < n; i++) {
    cin >> k[i];
  }
  int ans = INF;
  for (int a1 = 0; a1 < 4; a1++)
    for (int a2 = 0; a2 < 4; a2++)
      for (int a3 = 0; a3 < 4; a3++)
        for (int a4 = 0; a4 < 4; a4++)
          for (int a5 = 0; a5 < 4; a5++)
            for (int a6 = 0; a6 < 4; a6++)
              for (int a7 = 0; a7 < 4; a7++)
                for (int a8 = 0; a8 < 4; a8++) {
                  p[a1] += k[0];
                  p[a2] += k[1];
                  p[a3] += k[2];
                  p[a4] += k[3];
                  p[a5] += k[4];
                  p[a6] += k[5];
                  p[a7] += k[6];
                  p[a8] += k[7];
                  q[a1]++;
                  q[a2]++;
                  q[a3]++;
                  q[a4]++;
                  q[a5]++;
                  q[a6]++;
                  q[a7]++;
                  q[a8]++;
                  if (p[0] == 0 || p[1] == 0 || p[2] == 0) continue;
                  ans = min(ans, abs(p[0] - a) + abs(p[1] - b) + abs(p[2] - c) +
                                     10 * (max(1, q[0]) - 1) +
                                     10 * (max(1, q[1]) - 1) +
                                     10 * (max(1, q[2]) - 1));
                  p[0] = 0;
                  p[1] = 0;
                  p[2] = 0;
                  p[3] = 0;
                  q[0] = 0;
                  q[1] = 0;
                  q[2] = 0;
                  q[3] = 0;
                }
  cout << ans << endl;
}
