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