#include <bits/stdc++.h>
signed main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int64_t n, a, b, c;
  std::cin >> n >> a >> b >> c;
  n = (4 - (n % 4)) % 4;
  if (n == 0) {
    std::cout << 0 << '\n';
  }
  if (n == 1) {
    std::cout << std::min({a, c * 3, c + b}) << '\n';
  }
  if (n == 2) {
    std::cout << std::min({a + b + c, a * 2, b, c * 2}) << '\n';
  }
  if (n == 3) {
    std::cout << std::min({a * 3, a + b, c}) << '\n';
  }
  return 0;
}
