#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 8;
int N, A, B, C;
vector<int> l(MAX_N);
int dfs(int depth, int a, int b, int c) {
  if (depth == N) {
    if (a == 0 || b == 0 || c == 0) {
      return 99999999;
    }
    return abs(a - A) + abs(b - B) + abs(c - C) - 30;
  } else {
    int notUse = dfs(depth + 1, a, b, c);
    int useForA = dfs(depth + 1, a + l[depth], b, c);
    int useForB = dfs(depth + 1, a, b + l[depth], c);
    int useForC = dfs(depth + 1, a, b, c + l[depth]);
    return min({notUse, useForA, useForB, useForC});
  }
}
int main() {
  cin >> N >> A >> B >> C;
  for (int i = 0; i < (N); i++) {
    cin >> l[i];
  }
  cout << dfs(0, 0, 0, 0);
  cout << endl;
  return 0;
}
