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