#include <bits/stdc++.h>
using namespace std;
int f[4], n, ans = 99999999;
bool vis[8];
int num[8];
void dfs(int a, int b, int c, int len, int now, int m) {
  vis[now] = 1;
  int a1 = a, b1 = b, c1 = c;
  if (a1 > b1) swap(a1, b1);
  if (a1 > c1) swap(a1, c1);
  if (b1 > c1) swap(b1, c1);
  ans = min(ans, abs(a1 - f[1]) + abs(b1 - f[2]) + abs(c1 - f[3]) + m);
  if (ans == 0) return;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(a + num[i], b, c, len - 1, i, m + 10);
      dfs(a, b + num[i], c, len - 1, i, m + 10);
      dfs(a, b, c + num[i], len - 1, i, m + 10);
    }
  }
  vis[now] = 0;
}
int main() {
  cin >> n >> f[1] >> f[2] >> f[3];
  sort(f + 1, f + 4);
  for (int i = 1; i <= n; i++) {
    cin >> num[i];
  }
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; i <= n; i++)
      for (int k = j + 1; k <= n; k++) {
        vis[i] = vis[j] = vis[k] = 1;
        dfs(num[i], num[j], num[k], n, 0, 0);
        vis[i] = vis[j] = vis[k] = 0;
      }
  cout << ans;
  return 0;
}
