import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); long a = sc.nextInt(); long b = sc.nextInt(); long c = sc.nextInt(); int max = 1; for (int i = 2; pow(b, i) < (n - 1) * a; i++) { max = i; } PriorityQueue queue = new PriorityQueue<>(); queue.add(new Path(1, 0)); long[] costs = new long[n * 2]; Arrays.fill(costs, Long.MAX_VALUE); while (queue.size() > 0) { Path p = queue.poll(); if (costs[p.idx] <= p.value) { continue; } costs[p.idx] = p.value; if (p.idx == 0) { break; } if (p.idx == n) { queue.add(new Path(0, p.value)); continue; } queue.add(new Path((p.idx + 1) % (n * 2), p.value + a)); if (p.idx >= 2) { for (int i = 2; i <= max; i++) { queue.add(new Path(powmod(p.idx, i, n * 2), p.value + pow(b, i))); } } if (p.idx > 2 && p.idx < n) { queue.add(new Path(factmod(p.idx, n * 2), p.value + c)); } else if (p.idx >= n) { queue.add(new Path(0, p.value + c)); } } System.out.println(costs[0]); } static long pow(long x, int p) { long ans = 1; for (int i = 1; i <= p; i++) { ans *= x; } return ans; } static int powmod(long x, int p, int mod) { long ans = 1; for (int i = 1; i <= p; i++) { ans *= x; ans %= mod; } return (int)ans; } static int factmod(int x, int mod) { long ans = 1; for (int i = 2; i <= x; i++) { ans *= i; ans %= mod; } return (int)ans; } static class Path implements Comparable { int idx; long value; public Path(int idx, long value) { this.idx = idx; this.value = value; } public int compareTo(Path another) { return Long.compare(value, another.value); } } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }