#include <bits/stdc++.h>
using namespace std;
const int N = 9;
int l[N];
int n, a, b, c;
int dfs(int cur, int ca, int cb, int cc) {
  if (cur == n) {
    if (ca * cb * cc)
      return abs(a - ca) + abs(b - cb) + abs(c - cc);
    else
      return 1e9;
  }
  int ret0 = dfs(cur + 1, ca, cb, cc);
  int ret1 = dfs(cur + 1, ca + l[cur], cb, cc);
  int ret2 = dfs(cur + 1, ca, cb + l[cur], cc);
  int ret3 = dfs(cur + 1, ca, cb, cc + l[cur]);
  return min(min(ret0, ret1), min(ret2, ret3));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> a >> b >> c;
  for (int i = 0; i < n; i++) cin >> l[i];
  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}
