#include <bits/stdc++.h>
using namespace std;
int n, a[4];
int x[10];
int ans = 999999999;
int y[10][3] = {{1, 2, 3}, {1, 3, 2}, {2, 1, 3},
                {2, 3, 1}, {3, 1, 2}, {3, 2, 1}};
bool flag[4];
void dfs(int[], int, int);
int main() {
  scanf("%d%d%d%d", &n, &a[1], &a[2], &a[3]);
  for (int i = 1; i <= n; ++i) {
    if (x[i] == a[1]) flag[1] = true;
    if (x[i] == a[2]) flag[2] = true;
    if (x[i] == a[3]) flag[3] = true;
    scanf("%d", &x[i]);
  }
  if (flag[1] && flag[2] && flag[3]) {
    puts("0");
    return 0;
  }
  dfs(x, 0, n);
  cout << ans << endl;
  return 0;
}
void dfs(int k[], int diss, int len) {
  if (len < 3) {
    return;
  }
  int a1 = 9999999, b = 9999999, c = 99999999;
  for (int i = 1; i <= n; ++i) {
    if (!k[i]) continue;
    a1 = min(a1, abs(k[i] - a[1]));
    b = min(b, abs(k[i] - a[2]));
    c = min(c, abs(k[i] - a[3]));
  }
  ans = min(ans, a1 + b + c + diss);
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j) {
      if (!k[i] || !k[j]) continue;
      int g = k[i], h = k[j];
      k[i] += k[j];
      k[j] = 0;
      dfs(k, diss + 10, len - 1);
      k[i] = g;
      k[j] = h;
    }
  return;
}
