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