#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;
  } else if (n % 4 == 1) {
    if (3 * a <= b + a && 3 * a <= c) {
      cout << 3 * a;
    } else if (b + a <= 3 * a && b + a <= c) {
      cout << b + a;
    } else {
      cout << c;
    }
  } else if (n % 4 == 2) {
    if (2 * a <= b && 2 * a <= 2 * c) {
      cout << 2 * a;
    } else if (b <= 2 * a && b <= 2 * c) {
      cout << b;
    } else {
      cout << 2 * c;
    }
  } else if (n % 4 == 3) {
    if (a <= b + c && a <= 3 * c) {
      cout << a;
    } else if (b + c <= a && b + c <= 3 * c) {
      cout << b + c;
    } else {
      cout << 3 * c;
    }
  }
  return 0;
}
