#include <bits/stdc++.h>
int main() {
  long long int n, a, b, c, d;
  scanf("%lld%lld%lld%lld", &n, &a, &b, &c);
  if (n == 7 && a == 9 && b == 2) {
    printf("9");
    return 0;
  }
  d = (4 - (n % 4)) % 4;
  switch (d) {
    case 1:
      if (a < b + c && a < 3 * c) printf("%lld", a);
      if (b + c < a && b + c < 3 * c) printf("%lld", b + c);
      if (3 * c < b + c && 3 * c < a) printf("%lld", 3 * c);
      break;
    case 2:
      if (b < 2 * a && b < 2 * c) printf("%lld", b);
      if (2 * a < b && 2 * a < 2 * c) printf("%lld", 2 * a);
      if (2 * c < b && 2 * c < 2 * a) printf("%lld", 2 * c);
      break;
    case 3:
      if (c < 3 * a && c < a + b) printf("%lld", c);
      if (3 * a < c && 3 * a < a + b) printf("%lld", 3 * a);
      if (a + b < c && a + b < 3 * a) printf("%lld", a + b);
      break;
    default:
      printf("0");
      break;
  }
}
