#!/usr/bin/env python3
n, p, r, b = map(int, input().split())

def formula(k):
    return (k*r) + b*((k-1)*(k-2))/2

def f(x):
    short_length = n//(x+1)
    long_length = short_length + 1

    long_count = n-(short_length*(x+1))
    short_count = x-long_count

    short_time = (short_count+1) * formula(short_length)
    long_time = long_count * formula(long_length)

    pitstop_time = x*p

    return short_time + long_time + pitstop_time

left = 0
right = 10000000000000

while left < right - 1:
    m = (left + right) // 2
    if f(m) < f(m+1):
        right = m
    else:
        left = m
print(f(right))
