#include <bits/stdc++.h>
using namespace std;
long long n, a, b, c, ans, t, v;
bool f;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> a >> b >> c;
  t = 4 - (n % 4);
  if (t == 3)
    ans = min(c, min(3 * a, a + b));
  else if (t == 2)
    ans = min(b, min(2 * a, 2 * c));
  else if (t == 1)
    ans = min(a, min(3 * c, b + c));
  else
    ans = 0;
  cout << ans << endl;
  return (0);
}
