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