#include <bits/stdc++.h>
using namespace std;
int mp(int A, int B, int C, vector<int> bamboo) {
  int ans = INT_MAX;
  for (int i = 0; i < bamboo.size(); i++) {
    for (int j = 0; j < bamboo.size(); j++) {
      if (i == j) break;
      for (int k = 0; k < bamboo.size(); k++) {
        if (i == k or j == k) break;
        ans = min(ans,
                  abs(A - bamboo[i]) + abs(B - bamboo[j]) + abs(C - bamboo[k]));
      }
    }
  }
  if (bamboo.size() == 3 or ans <= 10) return ans;
  int test = 0;
  for (int i = 0; i < bamboo.size(); i++) {
    for (int j = 0; j < i; j++) {
      vector<int> newbb(bamboo);
      newbb.push_back(newbb[i] + newbb[j]);
      newbb.erase(newbb.begin() + i);
      newbb.erase(newbb.begin() + j);
      ans = min(ans, mp(A, B, C, newbb) + 10);
    }
  }
  return ans;
}
int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<int> bamboo(N);
  for (int i = 0; i < N; i++) cin >> bamboo[i];
  cout << mp(A, B, C, bamboo) << endl;
}
