#include <bits/stdc++.h>
using namespace std;
int tt = 1, ans = INT_MAX;
int abc[3];
int t[3];
int match() {
  int sum = 0;
  for (int i = 0; i < 3; ++i) {
    sum += abs(abc[i] - t[i]);
  }
  return sum;
}
int check(vector<int> v, int n) {
  int a = 2000;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      for (int k = j + 1; k < n; ++k) {
        t[0] = v[i], t[1] = v[j], t[2] = v[k];
        sort(t, t + 3);
        a = min(a, match());
      }
    }
  }
  return a;
}
void solve(vector<int> v, int n, int cost) {
  if (n < 3) return;
  ans = min(ans, check(v, n) + cost);
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      vector<int> temp = v;
      temp[i] = temp[i] + temp[j];
      temp.erase(temp.begin() + j);
      solve(temp, n - 1, cost + 10);
    }
  }
}
int main() {
  while (tt--) {
    int n;
    cin >> n >> abc[0] >> abc[1] >> abc[2];
    sort(abc, abc + 3);
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
      cin >> l[i];
    }
    solve(l, n, 0);
    cout << ans << endl;
  }
}
