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