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