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