#include <bits/stdc++.h>
int gcd(int a, int b) {
  if (!b)
    return a;
  else
    gcd(b, a % b);
}
int abs(int n) {
  if (n < 0) n *= -1;
  return n;
}
void longer(int *take, int *MP) {
  ++(*take);
  ++(*MP);
}
void shorter(int *take, int *MP) { ++(*MP); }
void attach(int *take1, int *take2, int *MP) {
  *take1 += *take2;
  *take2 = -1;
  *MP += 10;
}
int main(int argc, char const *argv[]) {
  int N, req[3];
  int MP = 0, min, x, y;
  int l[8], diff[8][8];
  scanf("%d%d%d%d", &N, &req[0], &req[1], &req[2]);
  for (int i = 0; i < N; ++i) scanf(" %d", &l[i]);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      diff[i][j] = -1;
    }
  }
  for (int k = 0; k < 3; ++k) {
    for (int s = 0; s < N; ++s) {
      if (req[k] == l[s]) {
        l[s] = -1;
        ++k;
      }
    }
    for (int i = 0; i < N; ++i) {
      if (l[i] == -1) continue;
      for (int j = 0; j < N; ++j) {
        if (i == j || l[j] == -1) continue;
        if (l[i] + l[j] == req[k]) {
          attach(&l[i], &l[j], &MP);
          ++k;
        } else {
          x = l[i] % req[k];
          y = abs(req[k] - (l[i] + l[j]) % req[k]);
          if (x < y)
            diff[i][j] = x;
          else
            diff[i][j] = y;
        }
      }
    }
    min = 0x007F;
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        if (diff[i][j] < min && diff[i][j] != -1) min = diff[i][j];
      }
    }
    MP += min;
  }
  printf("%d\n", MP);
  return 0;
}
