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