#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a, b, c;
  int x;
  scanf(
      "%I64d"
      "%I64d"
      "%I64d"
      "%I64d",
      &n, &a, &b, &c);
  if (n % 4 == 0)
    x = 0;
  else
    x = 4 * ((n / 4) + 1) - n;
  if (x == 0)
    printf("0");
  else if (x == 1) {
    int p = (a < 3 * c) ? a : 3 * c;
    int q = b + c;
    printf("%d", (p < q) ? p : q);
  } else if (x == 2) {
    int p = (2 * a < b) ? 2 * a : b;
    int q = 2 * c;
    printf("%d", (p < q) ? p : q);
  } else if (x == 3) {
    int p = (3 * a < c) ? 3 * a : c;
    int q = a + b;
    printf("%d", (p < q) ? p : q);
  }
  return 0;
}
