#include <bits/stdc++.h>
using namespace std;
long long int choose(long long int n, long long int m) {
  long long int ans = 0;
  long long int num = 1;
  long long int den = 1;
  for (long long int i = 0; i < m; i++) {
    num *= (n - i);
    num = num / (i + 1);
  }
  return num;
}
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6) {
    if (n % i == 0 || n % (i + 2) == 0) return false;
  }
  return true;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) {
    return b;
  } else {
    return gcd(b % a, a);
  }
}
bool sortDes(long long int i, long long int j) { return i > j; }
long long int bits(long long int n) {
  long long int count = 0;
  while (n != 0) {
    if (n % 2 != 0)
      count++;
    else
      ;
    n /= 2;
  }
  return count;
}
int main() {
  long long int i, j, k, n, a, b, c;
  cin >> n >> a >> b >> c;
  long long int req;
  req = 4 - n % 4;
  if (n % 4 == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (req == 1) {
    long long int u = INT_MAX;
    if (u > a) {
      u = a;
    }
    if (3 * c < u) {
      u = 3 * c;
    }
    if (b + c < u) {
      u = b + c;
    }
    cout << u << endl;
  } else if (req == 2) {
    long long int r = INT_MAX;
    if (r > 2 * a) {
      r = 2 * a;
    }
    if (r > b) {
      r = b;
    }
    if (r > 2 * c) {
      r = 2 * c;
    }
    cout << r << endl;
    return 0;
  } else if (req == 3) {
    long long int m = INT_MAX;
    if (a * 3 < m) {
      m = a * 3;
    }
    if (a + b < m) {
      m = a + b;
    }
    if (c < m) {
      m = c;
    }
    cout << m << endl;
  }
  return 0;
}
