#include <bits/stdc++.h>
using namespace std;
long long n, cost[5], num[5], ans = 1e18;
signed main() {
  cin >> n;
  n = n % 4;
  for (long long i = 1; i <= 3; i++) cin >> cost[i];
  for (long long i = 0; i <= 3; i++) {
    for (long long j = 0; j <= 3; j++) {
      for (long long k = 0; k <= 3; k++) {
        long long tot = i + j * 2 + k * 3 + n;
        if (tot % 4 == 0) {
          ans = min(ans, i * cost[1] + j * cost[2] + k * cost[3]);
        }
      }
    }
  }
  cout << ans << endl;
}
