#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c, cost;
  cin >> n >> a >> b >> c;
  long long k = 4 - (n % 4);
  if (n % 4 == 0)
    cout << "0\n";
  else if (k == 1) {
    long long cost_a = a;
    long long cost_b = b + c;
    long long cost_c = 3 * c;
    cout << min(min(cost_a, cost_b), cost_c);
    return 0;
  } else if (k == 2) {
    long long cost_a = 2 * a;
    long long cost_b = b;
    long long cost_c = 2 * c;
    cout << min(min(cost_a, cost_b), cost_c);
    return 0;
  } else {
    long long cost_a = 3 * a;
    long long cost_b = b + a;
    long long cost_c = c;
    cout << min(min(cost_a, cost_b), cost_c);
    return 0;
  }
  return 0;
}
