#include <bits/stdc++.h>
using namespace std;
template <class T>
T modpower(T a, T b, T MOD) {
  T ans = 1;
  while (b != 0) {
    if (b % 2 == 1) ans = (ans * a) % MOD;
    a = (a * a) % MOD;
    b /= 2;
  }
  return ans;
}
void init() {
  long long int n, a, b, c, ans;
  cin >> n >> a >> b >> c;
  if (n % 4 == 0)
    cout << "0\n";
  else {
    if (n % 4 == 3) {
      ans = min(a, min(c + b, 3 * c));
      cout << ans;
    } else if (n % 4 == 2) {
      ans = min(2 * a, min(b, 2 * c));
      cout << ans;
    } else {
      ans = min(3 * a, min(c, b + a));
      cout << ans;
    }
  }
}
int main() {
  clock_t time1 = clock();
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  init();
  clock_t time2 = clock();
  cerr << "Time: " << (double)(time2 - time1) / CLOCKS_PER_SEC * 100000
       << " seconds" << endl;
  return 0;
}
