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