#include <bits/stdc++.h>
using namespace std;
int chck(int arra) {
  int s = 0;
  for (int i = 0; i < 8; i++) {
    s += arra % 2;
    arra /= 2;
  }
  return s;
}
int min6(vector<int> Ldmy, int N, int A, int B, int C) {
  int ans = 0, sipi, w, ww, mini, ind, siz = 0;
  vector<int> L(N, 0);
  for (int i = 0; i < N; i++) {
    L[i] = Ldmy[i];
  }
  siz = (1 << N) - 1;
  vector<vector<int>> x = vector<vector<int>>(siz, vector<int>(2, 0));
  vector<int> LL(N, 0);
  x[0][0] = L[0];
  x[0][1] = 1 << 0;
  w = 1;
  ww = 0;
  for (int j = 1; j < N; j++) {
    x[w][0] = L[j];
    x[w][1] = 1 << j;
    w++;
    ww = w;
    for (int i = 0; i < ww - 1; i++) {
      if (x[i][0] + L[j] >= A) {
        x[w][0] = x[i][0] + L[j] + 10;
        x[w][1] = x[i][1] + (1 << j);
      } else {
        x[w][0] = x[i][0] + L[j] - 10;
        x[w][1] = x[i][1] + (1 << j);
      }
      w++;
    }
  }
  mini = 2000000000;
  ind = 0;
  for (int i = 0; i < siz; i++) {
    if (abs(x[i][0] - A) < mini) {
      if ((chck(x[i][1]) + 2) <= N) {
        ind = x[i][1];
        mini = abs(x[i][0] - A);
      }
    }
  }
  ans += mini;
  N--;
  w = 0;
  for (int i = 0; i < N + 1; i++) {
    if ((ind & (1 << i)) == 0) {
      LL[w] = L[i];
      w++;
    }
  }
  for (int i = 0; i < N; i++) {
    L[i] = LL[i];
  }
  siz = (1 << N) - 1;
  x[0][0] = L[0];
  x[0][1] = 1 << 0;
  w = 1;
  ww = 0;
  for (int j = 1; j < N; j++) {
    x[w][0] = L[j];
    x[w][1] = 1 << j;
    w++;
    ww = w;
    for (int i = 0; i < ww - 1; i++) {
      if (x[i][0] + L[j] >= B) {
        x[w][0] = x[i][0] + L[j] + 10;
        x[w][1] = x[i][1] + (1 << j);
      } else {
        x[w][0] = x[i][0] + L[j] - 10;
        x[w][1] = x[i][1] + (1 << j);
      }
      w++;
    }
  }
  mini = 2000000000;
  ind = 0;
  for (int i = 0; i < siz; i++) {
    if (abs(x[i][0] - B) < mini) {
      if ((chck(x[i][1]) + 1) <= N) {
        ind = x[i][1];
        mini = abs(x[i][0] - B);
      }
    }
  }
  ans += mini;
  N--;
  w = 0;
  for (int i = 0; i < N + 1; i++) {
    if ((ind & (1 << i)) == 0) {
      LL[w] = L[i];
      w++;
    }
  }
  for (int i = 0; i < N; i++) {
    L[i] = LL[i];
  }
  siz = (1 << N) - 1;
  x[0][0] = L[0];
  x[0][1] = 1 << 0;
  w = 1;
  ww = 0;
  for (int j = 1; j < N; j++) {
    x[w][0] = L[j];
    x[w][1] = 1 << j;
    w++;
    ww = w;
    for (int i = 0; i < ww - 1; i++) {
      if (x[i][0] + L[j] >= C) {
        x[w][0] = x[i][0] + L[j] + 10;
        x[w][1] = x[i][1] + (1 << j);
      } else {
        x[w][0] = x[i][0] + L[j] - 10;
        x[w][1] = x[i][1] + (1 << j);
      }
      w++;
    }
  }
  mini = 2000000000;
  ind = 0;
  for (int i = 0; i < siz; i++) {
    if (abs(x[i][0] - C) < mini) {
      if ((chck(x[i][1]) + 0) <= N) {
        ind = x[i][1];
        mini = abs(x[i][0] - C);
      }
    }
  }
  ans += mini;
  N--;
  w = 0;
  for (int i = 0; i < N + 1; i++) {
    if ((ind & (1 << i)) == 0) {
      LL[w] = L[i];
      w++;
    }
  }
  for (int i = 0; i < N; i++) {
    L[i] = LL[i];
  }
  return ans;
}
int main() {
  int N, A, B, C, rans;
  cin >> N >> A >> B >> C;
  vector<int> L(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  vector<int> LL(N, 0);
  for (int i = 0; i < N; i++) {
    LL[i] = L[i];
  }
  cout << min6(LL, N, A, B, C) << endl;
  return 0;
}
