#include <bits/stdc++.h>
using namespace std;
long long y[100010] = {};
long long yon(int x) {
  if (y[x] > 0) return y[x];
  long long res = 0;
  for (int i = 0; x > 0; i++) {
    res += (x % 4) * pow(10, i);
    x /= 4;
  }
  return y[x] = res;
}
int yonbit(int x, int i) {
  long long n = yon(x);
  string s = to_string(n);
  char c;
  if (s.size() - 1 - i >= 0)
    c = s[s.size() - 1 - i];
  else
    c = 0;
  return c - '0' + 0;
}
int main() {
  int n, a, b, c, l[10];
  cin >> n >> a >> b >> c;
  for (int i = (0); i < (n); ++i) {
    cin >> l[i];
  }
  int ans = (1000000001);
  for (int i = (0); i < (pow(4, n)); ++i) {
    int al = 0, bl = 0, cl = 0, mp = 0;
    for (int j = (0); j < (n); ++j) {
      int sb = yonbit(i, j);
      if (sb == 0) {
        if (al != 0) mp += 10;
        al += l[j];
      }
      if (sb == 1) {
        if (bl != 0) mp += 10;
        bl += l[j];
      }
      if (sb == 2) {
        if (cl != 0) mp += 10;
        cl += l[j];
      }
    }
    if (min({al, bl, cl}) <= 0) continue;
    mp += abs(al - a) + abs(bl - b) + abs(cl - c);
    ans = min(ans, mp);
  }
  cout << ans << endl;
}
