#include <bits/stdc++.h>
int N, A, B, C;
int l[10];
int ans = 114514;
int max(int a, int b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
void dfs(int pos, int box1, int box2, int box3) {
  if (pos >= N) {
    int mp = max(A - box1, box1 - A) + max(B - box2, box2 - B) +
             max(C - box3, box3 - C);
    if (ans > mp) {
      ans = mp;
    }
    return;
  }
  dfs(pos + 1, box1 + l[pos], box2, box3);
  dfs(pos + 1, box1, box2 + l[pos], box3);
  dfs(pos + 1, box1, box2, box3 + l[pos]);
  dfs(pos + 1, box1, box2, box3);
}
int main() {
  scanf("%d %d %d %d", &N, &A, &B, &C);
  int i;
  for (i = 0; i < N; i++) {
    scanf("%d", &l[i]);
  }
  return 0;
}
