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