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