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