#include <bits/stdc++.h>
using namespace std;
const int N = 35;
const int Mod = 1e9 + 7;
long long f[N];
int main() {
  long long n, a, b, c;
  while (cin >> n >> a >> b >> c) {
    long long ans = 1e18;
    for (int i = 1; i < N; i++) f[i] = 1e18;
    f[0] = 0;
    for (int i = 1; i <= 30; i++) {
      if (i >= 1) f[i] = min(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]);
    }
    if (n % 4 == 0) ans = 0;
    cout << ans << endl;
  }
}
