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