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