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