#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7, mxn = 1e6, inf = 1e10;
void solve() {
  long long n;
  cin >> n;
  n = n % 4 == 0 ? 0 : 4 - n % 4;
  if (n == 0) {
    cout << "0\n";
    return;
  }
  long long a, b, c;
  cin >> a >> b >> c;
  if (n == 1) {
    cout << min({a, 3 * c, c + b}) << "\n";
  } else if (n == 2) {
    cout << min({2 * a, b, 2 * c}) << "\n";
  } else {
    cout << min({3 * a, b + a, c}) << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
