#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, A, B, C;
  cin >> N >> A >> B >> C;
  if (N % 4 == 0) {
    cout << 0 << endl;
  } else if (N % 4 == 1) {
    cout << min(min(C, A + B), A * 3) << endl;
  } else if (N % 4 == 2) {
    cout << min(min(B, C + C), A + A) << endl;
  } else {
    cout << min(min(A, B + C), C * 3) << endl;
  }
  return 0;
}
