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