#include <bits/stdc++.h>
int INF = 10000;
int n;
int recursion(int i, int a, int b, int c);
int abs(int z);
std::vector<int> A(3), bam(10);
int main() {
  std::cin >> n;
  for (int i = 0; i < 3; i++) {
    std::cin >> A[i];
  }
  for (int i = 0; i < n; i++) {
    std::cin >> bam[i];
  }
  std::cout << recursion(0, 0, 0, 0) << std::endl;
  return 0;
}
int recursion(int i, int a, int b, int c) {
  if (i == n - 1) {
    if (std::min({a, b, c}) == 0) {
      return INF;
    } else {
      return abs(a - A[0]) + abs(b - A[1]) + abs(c - A[2]) - 30;
    }
  } else {
    int temp0 = recursion(i + 1, a, b, c);
    int temp1 = recursion(i + 1, a + bam[i], b, c);
    int temp2 = recursion(i + 1, a, b + bam[i], c);
    int temp3 = recursion(i + 1, a, b, c + bam[i]);
    return std::min({temp0, temp1, temp2, temp3});
  }
}
int abs(int z) {
  if (z >= 0) {
    return z;
  } else {
    return -z;
  }
}
