#include <bits/stdc++.h>
using namespace std;
const int maxn = 8 + 5;
int len[maxn], vis[maxn], sum[3], cost[3];
;
int n, goal[3], better;
void dfs(int sum[], int cost[]) {
  int tol = 0, tag = 0;
  for (int i = 0; i < 3; i++) {
    if (sum[i] > 0) tag++;
    tol += (cost[i] - 1) * 10;
    tol += fabs(sum[i] - goal[i]);
  }
  if (tag == 3) {
    better = min(better, tol);
  }
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    vis[i] = 1;
    for (int j = 0; j < 3; j++) {
      if (sum[j] > goal[j]) continue;
      sum[j] += len[i];
      cost[j] += 1;
      if (cost[j] <= n - 2) dfs(sum, cost);
      sum[j] -= len[i];
      cost[j] -= 1;
    }
    vis[i] = 0;
  }
}
int main() {
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i < 3; i++) scanf("%d", &goal[i]);
    for (int i = 0; i < n; i++) {
      scanf("%d", &len[i]);
    }
    better = 0x3f3f3f3f;
    memset(vis, 0, sizeof(vis));
    memset(sum, 0, sizeof(sum));
    memset(cost, 0, sizeof(cost));
    dfs(sum, cost);
    printf("%d\n", better);
  }
  return 0;
}
