#include <bits/stdc++.h>
using namespace std;
int n, a, b, c;
int solve(vector<int> val) {
  if (val.size() == 3) {
    sort(val.begin(), val.end());
    return abs(val[0] - c) + abs(val[1] - b) + abs(val[2] - a);
  }
  int best = INT_MAX;
  sort(val.begin(), val.end());
  for (int i = 0; i < val.size(); i++) {
    for (int j = i + 1; j < val.size(); j++) {
      for (int k = i + 1; k < val.size(); k++) {
        best = min(best, abs(val[i] - c) + abs(val[j] - b) + abs(val[k] - a));
      }
    }
  }
  for (int i = 0; i < val.size(); i++) {
    for (int j = i + 1; j < val.size(); j++) {
      vector<int> nv;
      nv.push_back(val[i] + val[j]);
      for (int x = 0; x < val.size(); x++) {
        if (x == i || x == j) continue;
        nv.push_back(val[x]);
      }
      best = min(best, 10 + solve(nv));
    }
  }
  return best;
}
int main() {
  cin >> n >> a >> b >> c;
  vector<int> t(n);
  for (int i = 0; i < n; i++) cin >> t[i];
  cout << solve(t);
}
