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