#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 8;
int N, A, B, C;
int li[MAX_N];
int tb[MAX_N][MAX_N];
int main() {
  scanf("%d %d %d %d", &N, &A, &B, &C);
  for (int i = 0; i < N; i++) scanf("%d", &li[i]);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i != j) tb[i][j] = li[i] + li[j];
    }
  }
  int abc[3] = {A, B, C};
  sort(abc, abc + 3);
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    int res = 10000000;
    int ck = 0;
    for (int j = 0; j < N; i++) {
      if (abs(li[j] - abc[3 - i - 1]) <= 10) {
        res = min(abs(li[j] - abc[3 - i - 1]), res);
        ck = j;
      }
    }
    if (res > 10) {
      for (int j = 0; j < N; j++) {
        for (int k = 0; k < N; k++) {
          if (j != k) {
            if (tb[j][k] == abc[3 - i - 1]) {
              res = 10;
              li[j] = 0;
              li[k] = 0;
              j = N;
              k = N;
            }
          }
        }
      }
    } else {
      li[ck] = 0;
    }
    if (res > 10) {
      for (int j = 0; j < N; i++) {
        res = min(abs(li[j] - abc[3 - i - 1]), res);
        ck = j;
      }
      li[ck] = 0;
    }
    ans += res;
  }
  printf("%d\n", ans);
  return 0;
}
