#include <bits/stdc++.h>
using namespace std;
long long N;
long long A[10];
vector<long long> L(10);
long long magic(long long n, vector<long long> l) {
  vector<long long> ll;
  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++) {
        ll = l;
        ll[i] += ll[j];
        ll.erase(ll.begin() + j);
        M = min(M, magic(n - 1, ll) + 10);
      }
      ll = l;
      ll.erase(ll.begin() + i + 1);
      M = min(M, magic(n - 1, ll));
    }
    return M;
  }
  sort(l.begin(), l.begin() + 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;
}
