#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
int main() {
  long long n, a, b, c;
  while (scanf("%lld%lld%lld%lld", &n, &a, &b, &c) != EOF) {
    long long cnt = n % 4;
    long long ans = INF;
    if (cnt == 0)
      printf("0\n");
    else if (cnt == 1) {
      ans = min(3 * a, c);
      ans = min(a + b, ans);
      printf("%lld\n", ans);
    } else if (cnt == 2) {
      ans = min(2 * a, b);
      ans = min(ans, 2 * c);
      printf("%lld\n", ans);
    } else {
      ans = min(a, 3 * c);
      ans = min(ans, b + c);
      printf("%lld\n", ans);
    }
  }
  return 0;
}
