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