#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long A, B, C, N;
  cin >> N >> A >> B >> C;
  vector<long long> l(N);
  for (auto& i : l) {
    cin >> i;
  }
  vector<long long> dp;
  vector<long long> t(6);
  long long tmp1 = 0, tmp2 = 0, tmp3 = 0;
  long long sti1 = 0, sti2 = 0, sti3 = 0;
  for (long long a = 0; a <= N; a++) {
    for (long long b = a + 1; b <= N; b++) {
      for (long long c = b + 1; c <= N; c++) {
        for (long long d = c + 1; d <= N; d++) {
          tmp1 = tmp2 = tmp3 = 0;
          sti1 = sti2 = sti3 = -1;
          for (long long i = a; i < b; i++) {
            tmp1 += l[i];
            sti1++;
          }
          for (long long i = b; i < c; i++) {
            tmp2 += l[i];
            sti2++;
          }
          for (long long i = c; i < d; i++) {
            tmp3 += l[i];
            sti3++;
          }
          t[0] = abs(A - tmp1) + abs(B - tmp2) + abs(C - tmp3);
          t[1] = abs(A - tmp1) + abs(B - tmp3) + abs(C - tmp2);
          t[2] = abs(A - tmp2) + abs(B - tmp1) + abs(C - tmp3);
          t[3] = abs(A - tmp2) + abs(B - tmp3) + abs(C - tmp1);
          t[4] = abs(A - tmp3) + abs(B - tmp1) + abs(C - tmp2);
          t[5] = abs(A - tmp3) + abs(B - tmp2) + abs(C - tmp1);
          sort(t.begin(), t.end());
          dp.push_back((sti1 + sti2 + sti3) * 10 + t[0]);
        }
      }
    }
  }
  sort(dp.begin(), dp.end());
  cout << dp[0] << endl;
  return 0;
}
