#include <bits/stdc++.h>
using namespace std;
int l[9];
int n, a, b, c;
int ans;
void dfs(int number, int A, int B, int C) {
  if (number == n) {
    int answer = abs(A - a) + abs(B - b) + abs(C - c);
    if (A > 0 && B > 0 && C > 0) ans = min(ans, answer);
    return;
  } else {
    if (number == 0) ans = 1e9;
    dfs(number + 1, A + l[number], B, C);
    dfs(number + 1, A, B + l[number], C);
    dfs(number + 1, A, B, C + l[number]);
    dfs(number + 1, A, B, C);
    return;
  }
}
int main() {
  cin >> n >> a >> b >> c;
  for (int i = 0; i < n; i++) cin >> l[i];
  dfs(0, 0, 0, 0);
  cout << ans << endl;
}
