#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n;
  cin >> n;
  long long a, b, c;
  cin >> a >> b >> c;
  long long ans = 1e10;
  for (long long i = 0; i < (long long)5; ++i) {
    for (long long j = 0; j < (long long)5; ++j) {
      for (long long k = 0; k < (long long)5; ++k) {
        if ((1 * i + 2 * j + 3 * k + n) % 4 == 0)
          ans = min(ans, a * i + b * j + c * k);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
