#include <bits/stdc++.h>
char s[1005];
int main() {
  long long n, a, b, c;
  long long ans, Min;
  scanf("%lld%lld%lld%lld", &n, &a, &b, &c);
  Min = 3 * a;
  for (int i = 0; i <= 3; i++) {
    for (int j = 0; j <= 3; j++) {
      for (int h = 0; h <= 3; h++) {
        if ((n + i + 2 * j + 3 * h) % 4 == 0) {
          ans = i * a + b * j + c * h;
          if (ans <= Min) Min = ans;
        }
      }
    }
  }
  printf("%lld\n", Min);
}
