#include <bits/stdc++.h>
using namespace std;
long long ans = ((long long)(1 << 31) * (long long)(1 << 31)), n, a, b, c;
long long dfs(long long k) {
  if (k > 11) return ((long long)(1 << 31) * (long long)(1 << 31));
  if ((n + k) % 4 == 0) return 0;
  return min({a + dfs(k + 1), b + dfs(k + 2), c + dfs(k + 3)});
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> a >> b >> c;
  cout << dfs(0) << '\n';
}
