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