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