#include <bits/stdc++.h>
using namespace std;
int A, B, C, N;
int L[8];
int V[3];
int f() {
  if (V[0] == 0 || V[1] == 0 || V[2] == 0) return 1 << 28;
  return abs(V[0] - C) + abs(V[1] - B) + abs(V[2] - A);
}
int dfs(int idx) {
  if (idx == N) return f();
  V[0] += L[idx];
  int ret = 10 + dfs(idx + 1);
  V[0] -= L[idx];
  V[1] += L[idx];
  ret = min(ret, 10 + dfs(idx + 1));
  V[1] -= L[idx];
  V[2] += L[idx];
  ret = min(ret, 10 + dfs(idx + 1));
  V[2] -= L[idx];
  ret = min(ret, dfs(idx + 1));
}
int main() {
  ios::sync_with_stdio(false);
  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  cout << dfs(0) - 30 << endl;
}
