#include <bits/stdc++.h>
const int MOD = 1000000007;
const int INF = 1000000000;
using namespace std;
int n, a, b, c;
vector<int> L;
int ans = 1e9;
void dfs(vector<int> nums, int rest, int merge) {
  sort(nums.begin(), nums.end());
  vector<int> save = nums;
  do {
    ans = min(ans, abs(a - nums[0]) + abs(b - nums[1]) + abs(c - nums[2]) +
                       10 * merge);
  } while (next_permutation(nums.begin(), nums.end()));
  if (rest) {
    sort(nums.begin(), nums.end());
    for (int i = 0; i < int(nums.size()) - 1; i++) {
      for (int j = i + 1; j < int(nums.size()); j++) {
        nums = save;
        int newlength = nums[i] + nums[j];
        nums[i] = newlength;
        nums.erase(nums.begin() + j);
        dfs(nums, rest - 1, merge + 1);
      }
    }
  }
}
int main(int argc, char const* argv[]) {
  cin >> n >> a >> b >> c;
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    L.push_back(l);
  }
  sort(L.begin(), L.end());
  dfs(L, n - 3, 0);
  cout << ans << endl;
  return 0;
}
