#include <bits/stdc++.h>
using namespace std;
long long n, a, b, c;
const long long inf = (1LL << 62);
int main() {
  long long minim = inf;
  cin >> n >> a >> b >> c;
  for (int i = 0; i <= 3; ++i) {
    for (int j = 0; j <= 3; ++j)
      for (int k = 0; k <= 3; ++k) {
        if ((n + i + 2 * j + 3 * k) % 4 == 0) {
          minim = min(minim, i * a + j * b + c * k);
        }
      }
  }
  cout << minim;
  return 0;
}
