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