#include <bits/stdc++.h>
const int mod = 1e9 + 7;
using namespace std;
long long dx[4] = {1, -1, 0, 0};
long long dy[4] = {0, 0, 1, -1};
long long N, M, X, Y, A, B, C, Q, K, R, W, H, P, L;
string S, T;
long long ans;
long long x[101010];
long long y[101010];
long long a[201010];
long long b[101010];
long long c[101010];
long long t[101010];
long long p[101010];
long long n[101010];
long long l[101010];
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
struct Edge {
  long long to, cost;
  Edge(int to, int cost) : to(to), cost(cost) {}
};
vector<vector<Edge> > graph;
vector<long long> dist;
int main() {
  ans = 1e18;
  cin >> N >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  for (long long i = (0); i < (N); ++i) {
    cin >> l[i];
  }
  for (long long i = (0); i < (pow(4, N) + 1); ++i) {
    long long num = i;
    long long tmp[20];
    long long mp = 0;
    long long num1 = 0;
    long long num2 = 0;
    for (long long j = (0); j < (N + 10); ++j) {
      tmp[j] = 10000;
    }
    for (long long j = (1); j < (4); ++j) {
      tmp[j] = 0;
    }
    for (long long j = (0); j < (N); ++j) {
      if (num % 4 != 0) {
        mp += 10;
        tmp[num % 4] += l[j];
      } else {
        tmp[num1] = l[j];
        if (num1 == 0) {
          num1 = 4;
        } else {
          num1++;
        }
      }
      num = num / 4;
    }
    num1--;
    for (long long j = (1); j < (4); ++j) {
      if (tmp[j] == 0) {
        tmp[j] = 10000;
      }
    }
    num1 = (long long)max((long long)4, num1);
    sort(tmp, tmp + num1);
    for (long long j = (0); j < (num1); ++j) {
      for (long long k = (i + 1); k < (num1); ++k) {
        for (long long l = (k + 1); l < (num1); ++l) {
          num2 = abs(a[0] - tmp[j]) + abs(a[1] - tmp[k]) + abs(a[2] - tmp[l]);
          ans = min(num2 + mp, ans);
          if (i == 4 + 16 + 64) {
            cerr << num2 << " " << mp << endl;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
