#include <bits/stdc++.h>
using namespace std;
const int INF = int(1e9);
long long n, m;
long long a, b, c;
long long used[111111];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  cin >> a >> b >> c;
  n %= 4;
  if (n == 1)
    cout << min(a + a + a, min(b + a, c));
  else if (n == 2)
    cout << min(a + a, min(b, c + c));
  else if (n == 3)
    cout << min(a, min(b + c, c + c + c));
  else
    cout << 0;
  return 0;
}
