#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 24;
const int M = 1000 + 24;
const long long INF = 1e15;
int n, m, t;
long long a, b, c;
int main() {
  while (scanf("%d%lld%lld%lld", &n, &a, &b, &c) != EOF) {
    long long MAX = INF;
    m = n % 4;
    for (int i = 0; i <= 4; i++)
      for (int j = 0; j <= 4; j++)
        for (int z = 0; z <= 4; z++)
          if ((m + i + j * 2 + z * 3) % 4 == 0) {
            MAX = min(MAX, (long long)(i * a + j * b + z * c));
          }
    printf("%lld\n", MAX);
  }
}
