#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const long long mod = 1e9 + 7;
long long dx[4] = {1, 0, -1, 0};
long long dy[4] = {0, 1, 0, -1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, a, b, c, ans = 0;
  while (cin >> n >> a >> b >> c) {
    ans = 0;
    vector<long long> l;
    for (int i = 0; i < n; ++i) {
      long long x;
      cin >> x;
      if (x == a)
        a = 0, n--;
      else if (x == b)
        b = 0, n--;
      else if (x == c)
        c = 0, n--;
      else
        l.push_back(x);
    }
    sort((l).begin(), (l).end());
    if (a > 0) {
      for (int i = 0; i < n; ++i) {
        if (abs(l[i] - a) < 10) {
          ans += abs(l[i] - a);
          a = 0;
          l.erase(l.begin() + i);
          n--;
        }
      }
    }
    if (b > 0) {
      for (int i = 0; i < n; ++i) {
        if (abs(l[i] - b) < 10) {
          ans += abs(l[i] - b);
          b = 0;
          l.erase(l.begin() + i);
          n--;
        }
      }
    }
    if (c > 0) {
      for (int i = 0; i < n; ++i) {
        if (abs(l[i] - c) < 10) {
          ans += abs(l[i] - c);
          c = 0;
          l.erase(l.begin() + i);
          n--;
        }
      }
    }
    vector<long long> m = l;
    if (a > 0) {
      long long mi = 1000000000000000000LL, bi;
      for (int bit = 0; bit < (1 << n); ++bit) {
        long long sum = 0, num = 0;
        for (int i = 0; i < n; ++i) {
          if (bit & (1 << i)) {
            sum += l[i];
            num++;
          }
        }
        if (sum != 0) {
          if (mi > abs(a - sum) + ((num - 1) * 10)) {
            bi = bit;
            mi = abs(a - sum) + ((num - 1) * 10);
          }
        }
      }
      for (int i = 0; i < n; ++i) {
        if (bi & (1 << i)) {
          l.erase(l.begin() + i);
          n--;
        }
      }
      ans += mi;
    }
    if (c > 0) {
      long long mi = 1000000000000000000LL, bi;
      for (int bit = 0; bit < (1 << n); ++bit) {
        long long sum = 0, num = 0;
        for (int i = 0; i < n; ++i) {
          if (bit & (1 << i)) {
            sum += l[i];
            num++;
          }
        }
        if (sum != 0) {
          if (mi > abs(c - sum) + ((num - 1) * 10)) {
            bi = bit;
            mi = abs(c - sum) + ((num - 1) * 10);
          }
        }
      }
      for (int i = 0; i < n; ++i) {
        if (bi & (1 << i)) {
          l.erase(l.begin() + i);
          n--;
        }
      }
      ans += mi;
    }
    if (b > 0) {
      long long mi = 1000000000000000000LL, bi;
      for (int bit = 0; bit < (1 << n); ++bit) {
        long long sum = 0, num = 0;
        for (int i = 0; i < n; ++i) {
          if (bit & (1 << i)) {
            sum += l[i];
            num++;
          }
        }
        if (sum != 0) {
          if (mi > abs(b - sum) + ((num - 1) * 10)) {
            bi = bit;
            mi = abs(b - sum) + ((num - 1) * 10);
          }
        }
      }
      for (int i = 0; i < n; ++i) {
        if (bi & (1 << i)) {
          l.erase(l.begin() + i);
          n--;
        }
      }
      ans += mi;
    }
    cout << ans << endl;
  }
  return 0;
}
