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