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