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