#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  int l[n];
  for (int i(0); i < n; i++) {
    cin >> l[i];
  }
  bool d[n];
  for (int i(0); i < n; i++) {
    d[i] = true;
  }
  for (int i(0); i < n; i++) {
    if (l[i] <= 10) d[i] = false;
  }
  int mp(0);
  bool af, bf, cf;
  af = true;
  bf = true;
  cf = true;
  for (int i(0); i < n; i++) {
    if (a - l[i] < 10 && l[i] - a < 10 && d[i] == true) {
      mp += abs(a - l[i]);
      d[i] = false;
      af = false;
      break;
    }
    if (b - l[i] < 10 && l[i] - b < 10 && d[i] == true) {
      mp += abs(b - l[i]);
      d[i] = false;
      bf = false;
      break;
    }
    if (c - l[i] < 10 && l[i] - c < 10 && d[i] == true) {
      mp += abs(c - l[i]);
      d[i] = false;
      cf = false;
      break;
    }
  }
  bool afb, bfb, cfb;
  afb = true;
  bfb = true;
  cfb = true;
  if (af == true) {
    for (int i(0); i < n - 1; i++) {
      for (int j(i + 1); j < n; j++) {
        if (a - l[i] - l[j] < 10 && l[i] + l[j] - a < 10 && d[i] == true &&
            d[j] == true) {
          mp += 10;
          mp += abs(a - l[i] - l[j]);
          d[i] = false;
          d[j] = false;
          af = false;
          afb = false;
          break;
        }
      }
      if (afb == false) break;
    }
  }
  if (bf == true) {
    for (int i(0); i < n - 1; i++) {
      for (int j(i + 1); j < n; j++) {
        if (b - l[i] - l[j] < 10 && l[i] + l[j] - b < 10 && d[i] == true &&
            d[j] == true) {
          mp += 10;
          mp += abs(b - l[i] - l[j]);
          d[i] = false;
          d[j] = false;
          bf = false;
          bfb = false;
          break;
        }
      }
      if (bfb == false) break;
    }
  }
  if (cf == true) {
    for (int i(0); i < n - 1; i++) {
      for (int j(i + 1); j < n; j++) {
        if (c - l[i] - l[j] < 10 && l[i] + l[j] - c < 10 && d[i] == true &&
            d[j] == true) {
          mp += 10;
          mp += abs(c - l[i] - l[j]);
          d[i] = false;
          d[j] = false;
          cf = false;
          cfb = false;
          break;
        }
      }
      if (cfb == false) break;
    }
  }
  bool afbf, bfbf, cfbf;
  afbf = true;
  bfbf = true;
  cfbf = true;
  if (af == true) {
    for (int i(0); i < n - 2; i++) {
      for (int j(i + 1); j < n - 1; j++) {
        for (int k(j + 1); k < n; k++) {
          if (a - l[i] - l[j] - l[k] < 10 && l[i] + l[j] + l[k] - a < 10 &&
              d[i] == true && d[j] == true && d[k] == true) {
            mp += 20;
            mp += abs(a - l[i] - l[j] - l[k]);
            d[i] = false;
            d[j] = false;
            d[k] = false;
            af = false;
            afbf = false;
            break;
          }
        }
        if (afbf == false) break;
      }
      if (afbf == false) break;
    }
  }
  if (bf == true) {
    for (int i(0); i < n - 2; i++) {
      for (int j(i + 1); j < n - 1; j++) {
        for (int k(j + 1); k < n; k++) {
          if (b - l[i] - l[j] - l[k] < 10 && l[i] + l[j] + l[k] - b < 10 &&
              d[i] == true && d[j] == true && d[k] == true) {
            mp += 20;
            mp += abs(b - l[i] - l[j] - l[k]);
            d[i] = false;
            d[j] = false;
            d[k] = false;
            bf = false;
            break;
          }
        }
        if (bfbf == false) break;
      }
      if (bfbf == false) break;
    }
  }
  if (cf == true) {
    for (int i(0); i < n - 2; i++) {
      for (int j(i + 1); j < n - 1; j++) {
        for (int k(j + 1); k < n; k++) {
          if (c - l[i] - l[j] - l[k] < 10 && l[i] + l[j] + l[k] - c < 10 &&
              d[i] == true && d[j] == true && d[k] == true) {
            mp += 20;
            mp += abs(c - l[i] - l[j] - l[k]);
            d[i] = false;
            d[j] = false;
            d[k] = false;
            cf = false;
            break;
          }
        }
        if (cfbf == false) break;
      }
      if (cfbf == false) break;
    }
  }
  for (int i(0); i < n; i++) {
    if (d[i] == true) cout << i << endl;
  }
  int max(0);
  for (int i(0); i < n; i++) {
    if (max < l[i]) max = l[i];
  }
  if (af == true) {
    int min(max);
    for (int i(0); i < n; i++) {
      int t = abs(a - l[i]);
      if (min > t && d[i] == true) min = t;
    }
    mp += min;
  }
  if (bf == true) {
    int min(max);
    for (int i(0); i < n; i++) {
      int t = abs(b - l[i]);
      if (min > t && d[i] == true) min = t;
    }
    mp += min;
  }
  if (cf == true) {
    int min(max);
    for (int i(0); i < n; i++) {
      int t = abs(c - l[i]);
      if (min > t && d[i] == true) {
        min = t;
      }
    }
    mp += min;
  }
  cout << mp << endl;
  return 0;
}
