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