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