#include <bits/stdc++.h>
using namespace std;
long long N;
long long A[10];
long long L[10];
long long magic(long long n, long long l[]) {
  long long ll[10] = {};
  if (n != 3) {
    long long M = 10000000000000000;
    for (long long i = 0; i < n - 1; i++) {
      for (long long j = i + 1; j < n; j++) {
        long long ll[10] = {};
        for (long long k = 0; k < i; k++) {
          ll[k] = l[k];
        }
        ll[i] = l[i] + l[j];
        for (long long k = i + 1; k < j; k++) {
          ll[k] = l[k];
        }
        for (long long k = j; k < n - 1; k++) {
          ll[k] = l[k + 1];
        }
        M = min(M, magic(n - 1, ll) + 10);
      }
      long long ll[10] = {};
      for (long long k = 0; k < i; k++) {
        ll[k] = l[k];
      }
      for (long long k = i; k < n - 1; k++) {
        ll[k] = l[k + 1];
      }
      M = min(M, magic(n - 1, ll));
    }
    return M;
  }
  sort(l, l + n);
  return abs(l[0] - A[0]) + abs(l[1] - A[1]) + abs(l[2] - A[2]);
}
signed main() {
  cin >> N;
  cin >> A[2] >> A[1] >> A[0];
  for (long long i = 0; i < N; i++) {
    cin >> L[i];
  }
  cout << magic(N, L) << endl;
  return 0;
}
