#include <bits/stdc++.h>
using namespace std;
int n, a, b, c;
long long ans, f[25];
int main() {
  memset(f, 0, sizeof(f));
  scanf("%d%d%d%d", &n, &a, &b, &c);
  ans = 0x3f3f3f3f;
  for (int i = 0; i < 20; i++) {
    if (i >= 1) f[i] = f[i - 1] + a;
    if (i >= 2) f[i] = min(f[i], f[i - 2] + b);
    if (i >= 3) f[i] = min(f[i], f[i - 3] + c);
    if ((n + i) % 4 == 0) ans = min(ans, f[i]);
  }
  printf("%d\n", ans);
  return 0;
}
