#include <bits/stdc++.h>
using namespace std;
int h[9];
int a, b, c, n;
int minn1 = INT_MAX, minn2 = INT_MAX, minn3 = INT_MAX;
void func1(int index, int height, int mp, int flag) {
  if (height == a) minn1 = min(minn1, mp);
  if (height <= a && flag != 0) func1(index, height + 1, mp + 1, 1);
  if (height >= 2 && height >= a && flag != 1)
    func1(index, height - 1, mp + 1, 0);
  for (int i = 1; i <= n; i++)
    if (i != index) func1(index, height + h[i], mp + 10, -1);
}
void func2(int index, int height, int mp, int flag) {
  if (height == b) minn2 = min(minn2, mp);
  if (height <= b && flag != 0) func2(index, height + 1, mp + 1, 1);
  if (height >= 2 && height >= b && flag != 1)
    func2(index, height - 1, mp + 1, 0);
  for (int i = 1; i <= n; i++)
    if (i != index) func2(index, height + h[i], mp + 10, -1);
}
void func3(int index, int height, int mp, int flag) {
  if (height == c) minn3 = min(minn3, mp);
  if (height <= c && flag != 0) func3(index, height + 1, mp + 1, 1);
  if (height >= 2 && height >= c && flag != 1)
    func3(index, height - 1, mp + 1, 0);
  for (int i = 1; i <= n; i++)
    if (i != index) func3(index, height + h[i], mp + 10, -1);
}
int main() {
  scanf("%d%d%d%d", &n, &a, &b, &c);
  for (int i = 1; i <= n; i++) scanf("%d", &h[i]);
  for (int i = 1; i <= n; i++) {
    func1(i, h[i], 0, -1);
    func2(i, h[i], 0, -1);
    func3(i, h[i], 0, -1);
  }
  printf("%d", minn1 + minn2 + minn3);
  return 0;
}
