#include <bits/stdc++.h>
using namespace std;
long long n, a, b, c;
int main() {
  cin >> n >> a >> b >> c;
  n %= 4;
  if (n == 0) cout << 0;
  if (n == 3) cout << min(a, min(b + c, c + c + c));
  if (n == 2) cout << min(b, min(a, c) * 2);
  if (n == 1) cout << min(c, min(a + b, a + a + a));
}
