#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  vector<int> target(3);
  cin >> n >> target[0] >> target[1] >> target[2];
  vector<int> l(n);
  for (ll i = 0; i < n; i++) cin >> l[i];
  int num_rep = pow(4, n);
  int ans = 1e9;
  vector<int> kind(n);
  vector<int> length(3);
  for (ll i = 0; i < num_rep; i++) {
    int tmp = i;
    int mp = 0;
    for (ll j = 0; j < 4; j++) length[j] = 0;
    for (ll j = 0; j < n; j++) {
      int r = tmp % 4;
      if (r != 3) {
        if (length[r] != 0) mp += 10;
        length[r] += l[j];
      }
      tmp /= 4;
    }
    for (ll j = 0; j < 3; j++) mp += abs(length[j] - target[j]);
    ans = min(mp, ans);
  }
  cout << ans << endl;
  return 0;
}
