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