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