#include <bits/stdc++.h>
int main() {
  int n, a[4];
  int i, j, k;
  long long int p[20], t;
  scanf("%d%d%d%d", &n, &a[1], &a[2], &a[3]);
  p[0] = 0;
  for (i = 1; i <= 11; i++) {
    p[i] = -1;
    for (k = 1; k <= 3 && i - k >= 0; k++) {
      if (p[i] == -1)
        p[i] = p[i - k] + a[k];
      else {
        if (p[i] > p[i - k] + a[k]) p[i] = p[i - k] + a[k];
      }
    }
  }
  k = n % 4;
  k = 4 - k;
  k %= 4;
  if (k) {
    if (p[k] < p[k + 4])
      t = p[k];
    else
      t = p[k + 4];
    if (t < p[k + 8])
      printf("%I64d", t);
    else
      printf("%I64d", p[k + 8]);
  } else
    printf("0");
  return 0;
}
