#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, B, C, X, mn, count, ans;
  ans = 0;
  cin >> N >> A >> B >> C;
  int L[9];
  for (int i = 1; i <= N; ++i) {
    L[i] = 0;
    cin >> L[i];
  }
  bool Acan = true;
  bool Bcan = true;
  bool Ccan = true;
  for (int i = 1; i <= N; ++i) {
    if (abs(A - L[i]) <= 10) {
      ans += abs(A - L[i]);
      L[i] = 0;
      Acan = false;
      break;
    }
  }
  for (int i = 1; i <= N; ++i) {
    if (abs(B - L[i]) <= 10) {
      ans += abs(B - L[i]);
      L[i] = 0;
      Bcan = false;
      break;
    }
  }
  for (int i = 1; i <= N; ++i) {
    if (abs(C - L[i]) <= 10) {
      ans += abs(C - L[i]);
      L[i] = 0;
      Ccan = false;
      break;
    }
  }
  X = A + B + C;
  if (Acan) X -= A;
  if (Bcan) X -= B;
  if (Ccan) X -= C;
  mn = 100000;
  for (int i = 0; i < 2; i = i + 1) {
    for (int j = 0; j < 3; j = j + 2) {
      for (int o = 0; o < 4; o = o + 3) {
        for (int p = 0; p < 5; p = p + 4) {
          for (int q = 0; q < 6; q = q + 5) {
            for (int w = 0; w < 7; w = w + 6) {
              for (int r = 0; r < 8; r = r + 7) {
                for (int t = 0; t < 9; t = t + 8) {
                  count = 0;
                  if (abs(X - L[i] - L[j] - L[o] - L[p] - L[q] - L[w] - L[r] -
                          L[t]) <= mn) {
                    mn = abs(X - L[i] - L[j] - L[o] - L[p] - L[q] - L[w] -
                             L[r] - L[t]);
                    if (i == 1) count += 1;
                    if (j == 1) count += 1;
                    if (o == 1) count += 1;
                    if (p == 1) count += 1;
                    if (q == 1) count += 1;
                    if (w == 1) count += 1;
                    if (r == 1) count += 1;
                    if (t == 1) count += 1;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  ans += 10 * count;
  ans += mn;
  cout << ans << endl;
}
