#include <bits/stdc++.h>
using namespace std;
namespace io {
inline void readl(long long &x) {
  x = 0;
  long long f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
inline void read(int &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
}  // namespace io
using namespace io;
int n, a, b, c, ans = 0x3f3f3f3f, p1, p2, p3;
int l[20];
bool vis[20];
inline void dfs(int res) {
  if (res > ans) return;
  if (a == -1 && b == -1 && c == -1) {
    ans = min(res, ans);
    return;
  }
  for (register int i = 1; i <= n; i++) {
    if (!vis[i]) {
      if (a != -1) {
        int aa = a;
        a = -1;
        vis[i] = 1;
        dfs(res + abs(aa - l[i]));
        vis[i] = 0;
        a = aa;
      } else if (b != -1) {
        int bb = b;
        b = -1;
        vis[i] = 1;
        dfs(res + abs(bb - l[i]));
        vis[i] = 0;
        b = bb;
      } else if (c != -1) {
        int cc = c;
        c = -1;
        vis[i] = 1;
        dfs(res + abs(cc - l[i]));
        vis[i] = 0;
        c = cc;
      }
    }
  }
  for (register int i = 1; i <= n; i++) {
    for (register int j = i + 1; j <= n; j++) {
      if (!vis[i] && !vis[j]) {
        vis[i] = vis[j] = 1;
        n++;
        l[n] = l[i] + l[j];
        dfs(res + 10);
        vis[i] = vis[j] = 0;
        l[n] = 0;
        n--;
      }
    }
  }
}
int main() {
  read(n), read(a), read(b), read(c);
  for (register int i = 1; i <= n; i++) {
    read(l[i]);
    if (l[i] == a) {
      vis[i] = 1;
      a = -1;
    }
    if (l[i] == b) {
      vis[i] = 1;
      b = -1;
    }
    if (l[i] == c) {
      vis[i] = 1;
      c = -1;
    }
  }
  dfs(0);
  printf("%d", ans);
  return 0;
}
