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