#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const long long MOD = (long long)1000000007;
const long long INF2 = (long long)100000000000000000;
int main() {
  int n;
  int a;
  int b;
  int c;
  cin >> n >> a >> b >> c;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  sort(l.rbegin(), l.rend());
  long long ans = INF;
  int p = -1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (i == j || j == k || k == i) continue;
        p = min(min(i, j), k) + 1;
        long long tmp = 0;
        long long lx = l[i];
        if (a <= l[i]) {
          tmp += l[i] - a;
        } else {
          if (a - l[i] <= 10) {
            tmp += a - l[i];
          } else {
            bool f = true;
            while (f && p < n) {
              int d = abs(a - lx);
              if (l[p] > 10) {
                int td = abs(a - (lx + l[p])) + 10;
                if (td < d) {
                  lx += l[p];
                  tmp += 10;
                  while (p != i && p != j && p != k) {
                    p++;
                  }
                } else {
                  f = false;
                }
              }
              if (p >= n) {
                f = false;
              }
            }
            tmp += abs(a - lx);
          }
        }
        long long ly = l[j];
        if (b <= l[j]) {
          tmp += l[j] - b;
        } else {
          if (b - l[j] <= 10) {
            tmp += b - l[j];
          } else {
            bool f = true;
            while (f && p < n) {
              int d = abs(b - ly);
              if (l[p] > 10) {
                int td = abs(b - (ly + l[p])) + 10;
                if (td < d) {
                  ly += l[p];
                  tmp += 10;
                  while (p != i && p != j && p != k) {
                    p++;
                  }
                } else {
                  f = false;
                }
              }
              if (p >= n) {
                f = false;
              }
            }
            tmp += abs(b - ly);
          }
        }
        long long lz = l[k];
        if (c <= l[k]) {
          tmp += l[k] - c;
        } else {
          if (c - l[k] <= 10) {
            tmp += c - l[k];
          } else {
            bool f = true;
            while (f && p < n) {
              int d = abs(c - lz);
              if (l[p] > 10) {
                int td = abs(c - (lz + l[p])) + 10;
                if (td < d) {
                  lz += l[p];
                  tmp += 10;
                  while (p != i && p != j && p != k) {
                    p++;
                  }
                } else {
                  f = false;
                }
              }
              if (p >= n) {
                f = false;
              }
            }
            tmp += abs(c - lz);
          }
        }
        ans = min(ans, tmp);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
