#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 100;
int main() {
  int SSS = 0;
  for (int i = 0; i < 100; i++) SSS++;
  long long int n, a, b, c;
  cin >> n >> a >> b >> c;
  if (n % 4 == 0) {
    cout << 0 << '\n';
    return 0;
  }
  if (n % 4 == 1) {
    cout << min(c, min(3 * a, a + b)) << '\n';
    return 0;
  }
  if (n % 4 == 2) {
    cout << min(b, min(a * 2, c * 2)) << '\n';
    return 0;
  }
  cout << min(a, min(c * 3, c + b)) << '\n';
  return 0;
}
