#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

struct CompressedVector {
	int size = 0;
	int tam = 0;
	pair<int,int> v[1000];
	inline int at(int idx, int &hint) const {
		while (hint+1 < tam && v[hint+1].first == idx) hint++;
		return v[hint].second;
	}
	inline void push_back(int x) {
		++size;
		if (!tam || v[tam-1].second != x) v[tam++] = {size, x};
	}
};

CompressedVector dp;
int n, c0, c1;

void solve() {
	scanf("%d %d %d", &n, &c0, &c1);

	dp.push_back(0);
	dp.push_back(c0+c1);

	int zero = 1;
	int zero_hint = 1;
	int one = 1;
	int one_hint = 1;
	long long zero_diff = c0+c1;
	long long one_diff = c0+c1;
	long long last_diff = c0+c1;

	for (int i = 3; i <= n; i++) {
		long long inc_one = one_diff + c1;
		long long inc_zero = zero_diff + c0;

		if (inc_zero < inc_one) {
			dp.push_back( inc_zero - last_diff );
			last_diff = inc_zero;
			zero++;
			zero_diff += dp.at( zero+1, zero_hint );
		}
		else {
			dp.push_back( inc_one - last_diff );
			last_diff = inc_one;
			one++;
			one_diff += dp.at( one+1, one_hint );
		}
	}

	long long ans = 0;
	long long diff = 0;
	int diff_hint = 1;
	for (int idx = 2; idx <= n; idx++) {
		diff += dp.at(idx, diff_hint);
		ans += diff;
	}

	printf("%lld\n", ans);
}

int main() {
    solve();
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
#include <ctime>
typedef  long long ll;
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef pair<int, int> pii;
typedef long double ld;
typedef unsigned int uint;
#define MAX 105
bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod = MOD) {
    x+=y; if (x>=mod) x-=mod;
    assert(x>=0 && x<mod);
}
void et() {
    puts("-1"); exit(0);
}

map<ll,ll> mp;
void pp(ll x) {
    cout<<x<<endl; exit(0);
}
void fmain() {
    int a,b; cin>>n>>a>>b;
    if (b<a) swap(a,b);
    if(b==0) pp(0);
    if (n==1) pp(a);
    else if (n==2) pp(a+b);
    else {
        if (a==0) {
            pp((ll)b*(n-1));
        }
        mp[a]++; mp[b]++; ll ans=a+b;
        for(int c=2;c<n;) {
            auto it = mp.begin();
            ll co = it->first, cnt = it->second;
            ll x = min((ll)n-c, cnt);
            ans -= x * co;
            ans += x * (co+a) + x*(co+b);
            mp[co+a]+=x; mp[co+b]+=x;
            mp[co]-=x;
            c+=x;
            if (mp[co]==0) mp.erase(co);
        }
        pp(ans);
    }
}
int main() {
    fmain();
    return 0;
}

#include<bits/stdc++.h>
typedef long long ll;
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stk[20];
inline void write(ll x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stk[++top]=x%10,x/=10;
    while(top)putchar(stk[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(ll x){write(x);putchar('\n');}
int c1,c2;
map<ll,int> mp;
priority_queue<ll,vector<ll>,greater<ll> > hp;
int main()
{
	int n=read(),c1=read(),c2=read();
	if(!c1&&!c2)return puts("0"),0;
	if(!c1||!c2)return pr2(1LL*(n-1)*max(c1,c2)),0;
	hp.push(0);mp[0]=1;int tot=1;
	ll ans=0;
	while(tot<n)
	{
		ll x=hp.top();hp.pop();
		int u=min(mp[x],n-tot);mp[x]-=u;
		tot+=u;ans+=1LL*u*(c1+c2)+x*u;
		if(!mp[x+c1])mp[x+c1]=u,hp.push(x+c1);
		else mp[x+c1]+=u;
		if(!mp[x+c2])mp[x+c2]=u,hp.push(x+c2);
		else mp[x+c2]+=u;
	}
	pr2(ans);
	return 0;
}

/*
ID: bqi3431
PROG: newlang
LANG: C++11
*/

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 200005;
const ld PI = 4*atan((ld)1);

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

namespace input {
    template<class T> void re(complex<T>& x);
    template<class T1, class T2> void re(pair<T1,T2>& p);
    template<class T> void re(vector<T>& a);
    template<class T, size_t SZ> void re(array<T,SZ>& a);

    template<class T> void re(T& x) { cin >> x; }
    void re(double& x) { string t; re(t); x = stod(t); }
    void re(ld& x) { string t; re(t); x = stold(t); }
    template<class Arg, class... Args> void re(Arg& first, Args&... rest) {
        re(first); re(rest...);
    }

    template<class T> void re(complex<T>& x) { T a,b; re(a,b); x = cd(a,b); }
    template<class T1, class T2> void re(pair<T1,T2>& p) { re(p.f,p.s); }
    template<class T> void re(vector<T>& a) { F0R(i,sz(a)) re(a[i]); }
    template<class T, size_t SZ> void re(array<T,SZ>& a) { F0R(i,SZ) re(a[i]); }
}

using namespace input;

namespace output {
    template<class T1, class T2> void pr(const pair<T1,T2>& x);
    template<class T, size_t SZ> void pr(const array<T,SZ>& x);
    template<class T> void pr(const vector<T>& x);
    template<class T> void pr(const set<T>& x);
    template<class T1, class T2> void pr(const map<T1,T2>& x);

    template<class T> void pr(const T& x) { cout << x; }
    template<class Arg, class... Args> void pr(const Arg& first, const Args&... rest) {
        pr(first); pr(rest...);
    }

    template<class T1, class T2> void pr(const pair<T1,T2>& x) {
        pr("{",x.f,", ",x.s,"}");
    }
    template<class T> void prContain(const T& x) {
        pr("{");
        bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; // const needed for vector<bool>
        pr("}");
    }
    template<class T, size_t SZ> void pr(const array<T,SZ>& x) { prContain(x); }
    template<class T> void pr(const vector<T>& x) { prContain(x); }
    template<class T> void pr(const set<T>& x) { prContain(x); }
    template<class T1, class T2> void pr(const map<T1,T2>& x) { prContain(x); }

    void ps() { pr("\n"); }
    template<class Arg> void ps(const Arg& first) {
        pr(first); ps(); // no space at end of line
    }
    template<class Arg, class... Args> void ps(const Arg& first, const Args&... rest) {
        pr(first," "); ps(rest...); // print w/ spaces
    }
}

using namespace output;

namespace io {
    void setIn(string s) { freopen(s.c_str(),"r",stdin); }
    void setOut(string s) { freopen(s.c_str(),"w",stdout); }
    void setIO(string s = "") {
        ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
        if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
    }
}

using namespace io;

template<class T> T invGeneral(T a, T b) {
    a %= b; if (a == 0) return b == 1 ? 0 : -1;
    T x = invGeneral(b,a);
    return x == -1 ? -1 : ((1-(ll)b*x)/a+b)%b;
}

template<class T> struct modular {
    T val;
    explicit operator T() const { return val; }
    modular() { val = 0; }
    template<class U> modular(const U& v) {
        val = (-MOD <= v && v <= MOD) ? v : v % MOD;
        if (val < 0) val += MOD;
    }
    friend ostream& operator<<(ostream& os, const modular& a) { return os << a.val; }
    friend bool operator==(const modular& a, const modular& b) { return a.val == b.val; }
    friend bool operator!=(const modular& a, const modular& b) { return !(a == b); }

    modular operator-() const { return modular(-val); }
    modular& operator+=(const modular& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
    modular& operator-=(const modular& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
    modular& operator*=(const modular& m) { val = (ll)val*m.val%MOD; return *this; }
    friend modular exp(modular a, ll p) {
        modular ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;
        return ans;
    }
    friend modular inv(const modular& a) { return invGeneral(a.val,MOD); }
    // inv is equivalent to return exp(b,b.mod-2) if prime
    modular& operator/=(const modular& m) { return (*this) *= inv(m); }

    friend modular operator+(modular a, const modular& b) { return a += b; }
    friend modular operator-(modular a, const modular& b) { return a -= b; }
    friend modular operator*(modular a, const modular& b) { return a *= b; }

    friend modular operator/(modular a, const modular& b) { return a /= b; }
};

typedef modular<int> mi;
typedef pair<mi,mi> pmi;
typedef vector<mi> vmi;
typedef vector<pmi> vpmi;

int T,N,X,Y;
// ll dp[5000001];
vpl dif;
ll i[2], dumb[2], dumbFac;
ll ccost;

ll get(int x) {
    if (i[x]) return dif[i[x]].f;
    return dif[i[x]].f+dumb[x]*Y;
}

void adv(int x) {
    if (i[x]) i[x] ++;
    else {
        if (dumb[x] < dumbFac) dumb[x] ++;
        else i[x] ++;
    }
}

ll solve() {
    re(N,X,Y); dif = {{X+Y,1}}; if (X < Y) swap(X,Y);
    if (min(X,Y) == 0) {
    	ps((ll)(N-1)*max(X,Y));
    	exit(0);
    }
    dumbFac = (X-1)/Y; // X+Y to X+Y*(1+dumbFac)
    F0R(j,2) i[j] = dumb[j] = 0;
    // dumbFac = 0;
    int cur = dumbFac+2;
    if (N <= cur) return (ll)X*(N-1)+(ll)Y*(N-1)*N/2; // (X+Y) to (X+Y*(cur-1))
    else ccost = (ll)X*(cur-1)+(ll)Y*(cur-1)*(cur)/2;
    dumb[1] = dumbFac;

    while (cur < N) {
        // ps(cur,N,ccost);
        ll mn = min(get(0)+X,get(1)+Y), num = 0;
        if (get(0)+X == mn) {
            num += dif[i[0]].s;
            adv(0);
        }
        if (get(1)+Y == mn) {
            num += dif[i[1]].s;
            adv(1);
        }
        dif.pb({mn,num}); // if (num > 1) ps(cur,mn,num);
        if (num > N-cur) return ccost+(ll)(N-cur)*mn;
        ccost += (ll)num*mn; cur += num;
    }
    return ccost;
}

int main() {
    // setIO("newlang");
    // re(T);
    F0R(i,1) ps(solve());
    // don't forget newline!
    // no range based for loops :(
    // use scanf, printf
}

/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do smth instead of nothing and stay organized
*/

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(LL x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(LL x){write(x);putchar('\n');}
int c1,c2;
map<LL,int> mp;
priority_queue<LL,vector<LL>,greater<LL> > hp;
int main()
{
	int n=read(),c1=read(),c2=read();
	if(!c1&&!c2)return puts("0"),0;
	if(!c1||!c2)return pr2(1LL*(n-1)*max(c1,c2)),0;
	hp.push(0);mp[0]=1;int tot=1;
	LL ans=0;
	while(tot<n)
	{
		LL x=hp.top();hp.pop();
		int u=min(mp[x],n-tot);mp[x]-=u;
		tot+=u;ans+=1LL*u*(c1+c2)+x*u;
		if(!mp[x+c1])mp[x+c1]=u,hp.push(x+c1);
		else mp[x+c1]+=u;
		if(!mp[x+c2])mp[x+c2]=u,hp.push(x+c2);
		else mp[x+c2]+=u;
	}
	pr2(ans);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

// 错误算法，偏的树会错…
// 不仅算法错了，即便对于不偏的树代码也有些错误

const ll MXL = 0x3f3f3f3f3f3f3f3fLL;

ll lim = 100000;
ll n;
ll a, b;

vector<pair<ll,ll>> p; // {index, sum}
multiset<ll> s;

void ini() {
	p = {{0, 0}};
	s = {0};
	for (int i = 0; i < lim || p.back().first - b == *s.begin(); ++i) { // 相同值的情况没考虑
		ll t = *s.begin();
		s.erase(s.begin());
		p.pb({t + b, -t + (t + a) + (t + b)});
		s.insert(t + a);
		s.insert(t + b);
	}
	ll pre = 0;
	for (auto &i : p)
		i.second = pre += i.second;
	//for (auto i : s)
		//cout << i << ' ';
	//cout << endl;
	//for (auto i : p)
		//cout << i.first << ' ' << i.second << endl;
}

ll count(ll deep) {
	if (deep <= p.back().first)
		return upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)) - p.begin();
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		re += upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)) - p.begin();
		re = min(re, MXL);
	}
	return re;
}

ll sum(ll deep) {
	if (deep <= p.back().first)
		return prev(upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)))->second;
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		auto t = prev(upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)));
		re += t->second + ll(t - p.begin() + 1) * i; // 减begin的时候要+1…因为prev过了…
		assert(re < MXL);
	}
	return re;
}

ll getDeep() {
	ll L = 0, R = MXL, M;
	while (L < R)
		if (M = L + R >> 1, count(M) >= n)
			R = M;
		else
			L = M + 1;
	return L;
}

int main() {
	cin >> n >> a >> b;
	if (a > b) swap(a, b);

	// 没判a,b为0的情况…wocao…

	if (a == 0 && b == 0) {
		cout << 0 << endl;
		return 0;
	}

	if (a == 0) {
		cout << (n - 1) * b << endl;
		return 0;
	}

	ini();

	ll h = getDeep();

	//cout << "deep = " << h << endl;
	//cout << "cnt = " << count(h) << endl;

	ll c = count(h);
	ll ans = sum(h);

	//cout << "sum = " << ans << endl;

	if (c > n)
		ans -= (c - n) * (h + (h - b + a) - (h - b));

	cout << ans << endl;

	return 0;
}

#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <bitset>
#include <random>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define vi vector<int>
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long ll;
typedef short inth;

const int N = 1;
const int M = N + 7;
const int MOD = 1e9 + 7;
const ll INF = 1e16 + 17;

map<ll, int> p;

int main() {
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    if (a > b)
        swap(a, b);
    if (!a) {
        printf("%lld\n", 1LL * (n - 1) * b);
        return 0;
    }
    set<ll> s;
    p[a]++;
    s.insert(a);
    p[b]++;
    s.insert(b);
    int cnt = 2;
    while (cnt < n) {
        ll cost = *s.begin();
        cerr << cnt << " | " << cost << " " << p[cost] << "\n";
        s.erase(s.begin());
        int add = min(n - cnt, p[cost]);
        p[cost + a] += add;
        s.insert(cost + a);
        p[cost + b] += add;
        s.insert(cost + b);
        p[cost] -= add;
        if (p[cost])
            s.insert(cost);
        cnt += add;
    }
    ll ans = 0;
    while (n) {
        ll cost = *s.begin();
        s.erase(s.begin());
        int x = min(n, p[cost]);
        n -= x;
        ans += cost * x;
    }
    printf("%lld\n", ans);
    return 0;
}

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#define clr(x) memset((x), 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define sz size()
#define For(i, st, en) for(int i=(st); i<=(int)(en); i++)
#define Ford(i, st, en) for(int i=(st); i>=(int)(en); i--)
#define forn(i, n) for(int i=0; i<(int)(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

#ifdef ROOM_311
__attribute__((destructor)) void fini_main()
{
	fprintf(stderr, "Execution time = %0.0lf ms\n", clock() * 1000.0 / CLOCKS_PER_SEC);
}
#endif

#define MY_RAND 1
#if MY_RAND
uint64_t rnd_data = 0xDEADBEEFDULL;
inline void my_srand(int seed) { rnd_data = ((uint64_t)seed << 16) | 0x330E; }
inline int my_rand() { rnd_data = rnd_data * 0x5DEECE66DULL + 0xB; return (rnd_data >> 17) & 0x7FFFFFFF; }
#define rand my_rand
#define srand my_srand
#endif

template <class _T> inline _T sqr(const _T &x) { return x * x; }
template <class _T> inline string tostr(const _T &a) { ostringstream os(""); os << a; return os.str(); }

// Types
typedef long double ld;
typedef long long i64;
typedef unsigned long long u64;
typedef pair < int, int > PII;
typedef set < int > SI;
typedef vector < int > VI;
typedef map < string, int > MSI;

// Constants
const ld PI = 3.1415926535897932384626433832795L;
const ld EPS = 1e-11;

const int MAXQ = 10240000;

int n, c0, c1;
int q[MAXQ];

void solve2()
{
	int cc = c0 + c1;
	i64 ans = 0;
	clr(q);
	int k = 0;
	for (n--; n; k++)
	{
		while (k < c1 && k % c0) ++k;
		int add;
		if (k < c1)
		{
			add = 1;
		}
		else
		{
			while (!q[k - c1]) ++k;
			add = min(n, q[k - c1]);
		}
		ans += (k + cc) * (i64)add;
		int k1 = k + c0;
		int k2 = k + c1;
		if (k1 >= c1 && k1 - c1 < MAXQ) q[k1 - c1] += add;
		if (k2 >= c1 && k2 - c1 < MAXQ) q[k2 - c1] += add;
		n -= add;
	}
	printf("%lld\n", ans);
}

int main()
{
#ifdef ROOM_311
	freopen("input.txt", "rt", stdin);
#endif
	cout << setiosflags(ios::fixed) << setprecision(10);

	scanf("%d%d%d", &n, &c0, &c1);
	if (c0 > c1) swap(c0, c1);
	if (!c0)
	{
		printf("%lld\n", c1 * (i64)(n - 1));
		return 0;
	}
	if (c1 / c0 > 1000000)
	{
		solve2();
		return 0;
	}
	map < i64, i64 > q;
	int cc = c0 + c1;
	n--;
	q[0] = 1;
	i64 ans = 0;
	while (n)
	{
		__typeof(q.begin()) it = q.begin();
		i64 k = it->first;
		int add = min((i64)n, it->second);
		q.erase(it);
		ans += (k + cc) * (i64)add;
		i64 k1 = k + c0;
		i64 k2 = k + c1;
		q[k1] += add;
		q[k2] += add;
		n -= add;
	}
	printf("%lld\n", ans);

	return 0;
}

/* Author haleyk10198 */
/* �@��:  haleyk10198 */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define MOD 1000000007
#define LINF (1LL<<60)
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))

using namespace std;
using namespace __gnu_pbds;

int n,c1,c2,now;
ll tt;
map<ll,ll> cnt;

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//ios_base::sync_with_stdio(false);
	cin>>n>>c1>>c2;
	if(c1>c2)
		swap(c1,c2);
	if(n==1){
		cout<<c1<<endl;
		return 0;
	}
	else if(c1==0){
		cout<<1LL*(n-1)*c2<<endl;
		return 0;
	}
	cnt[0]=now=1;
	while(now<n){
		auto x=cnt.begin();
		if(now+x->second>=n){
			tt+=1LL*(n-now)*(c1+c2);
			tt+=1LL*(x->first)*(n-now);
			break;
		}
		else{
			now+=x->second;
			tt+=1LL*x->first*x->second;
			tt+=1LL*x->second*(c1+c2);
			cnt[x->first+c1]+=x->second;
			cnt[x->first+c2]+=x->second;
			cnt.erase(x->first);
		}
	}
	cout<<tt<<endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, a, b; cin >> n >> a >> b;
    map<ll,ll> m;
    m[0] = 1; n--;
    if (min(a, b) == 0) {
        cout << n * (a + b) << endl;
        return 0;
    }
    while (n) {
        auto x = *m.begin();
        ll f = x.first, s = x.second;
        if (s <= n) {
            m[f + a] += s;
            m[f + b] += s;
            m.erase(m.begin());
            n -= s;
        }
        else {
            m[f + a] += n;
            m[f + b] += n;
            m[f] -= n; n = 0;
        }
    }
    ll r = 0;
    for (auto x : m) {
        ll f = x.first;
        ll s = x.second;
        r += f * s;
    }
    cout << r << endl;
    return 0;
}

// oct code title CF/CF715C.cpp

#ifndef OCT_CODE_INSERT_PREx2dDOCUMENT  // oct code insert pre-document
#define OCT_CODE_INSERT_PREx2dDOCUMENT

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#ifndef STL_BITS__2F_STDCx2Bx2Bx2FH
#define STL_BITS__2F_STDCx2Bx2Bx2FH
#include <bits/stdc++.h>
#endif

#define debug std::cerr << "Debug(" << __LINE__ << "): "
#ifdef ONLINE_JUDGE
#define cerr cout
#endif
#define pub push_back
#define pob pop_back
#define pup push
#define mkp make_pair
#define fir first
#define sec second
#define ite iterator
#define lob lower_bound
#define upb upper_bound
#define reg register

using uint8 = unsigned char;
using uint16 = unsigned short int;
using uint32 = unsigned int;
using uint64 = unsigned long long;
using int8 = signed char;
using int16 = short int;
using int32 = int;
using int64 = long long;
using ldb = long double;
using pi5 = std::pair<int32, int32>;
using pi6 = std::pair<int64, int64>;
using pi56 = std::pair<int32, int64>;
using pi65 = std::pair<int64, int32>;

namespace oct {

template <typename _Tp>
class priority_queue
    : public std::priority_queue<_Tp, std::vector<_Tp>, std::greater<_Tp> > {};

/* Array tn4 is the 4-direction changes in coordinate system.
 * The directions in order is {right, up, left, down}.
 */
const int tn4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int tn8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                       {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
const double exp = 1e-8;

void sync(int pre = 8);
template <typename _Tp>
_Tp &mad(_Tp &x, _Tp y);
template <typename _Tp>
_Tp &mid(_Tp &x, _Tp y);
template <typename _Tp>
bool in(_Tp x, _Tp l, _Tp r);
template <typename _Tp>
bool in(_Tp x, _Tp y, _Tp l, _Tp r);
template <typename _Tp>
_Tp sqr(_Tp x);
template <typename _Tp>
_Tp power(_Tp x, int64 m);
template <typename _Tp>
void sort(_Tp &x, _Tp &y);
template <typename _Tp1, typename _Tp2>
std::pair<_Tp1, _Tp2> operator+(std::pair<_Tp1, _Tp2> x,
                                std::pair<_Tp1, _Tp2> y);
template <typename _Tp>
_Tp &operator+=(_Tp &x, _Tp y);
template <typename _Tp>
_Tp gcd(_Tp &x, _Tp &y);

inline void sync(int pre) {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0), std::cout.tie(0);
    std::cout.flags(std::ios::fixed);
    std::cout.precision(pre);
    std::cout.setf(std::ios::showpoint);
}
template <typename _Tp>
inline _Tp &mad(_Tp &x, _Tp y) {
    return x = std::max(x, y);
}
template <typename _Tp>
inline _Tp &mid(_Tp &x, _Tp y) {
    return x = std::min(x, y);
}
template <typename _Tp>
inline bool in(_Tp x, _Tp l, _Tp r) {
    return l <= x && x <= r;
}
template <typename _Tp>
inline bool in(_Tp x, _Tp y, _Tp l, _Tp r) {
    return l <= x && y <= r;
}
template <typename _Tp>
inline _Tp sqr(_Tp x) {
    return x * x;
}
template <typename _Tp>
inline _Tp power(_Tp x, int64 m) {
    return m == 1 ? x : (m & 1 ? power(x * x, m / 2) * x : power(x * x, m / 2));
}
template <typename _Tp>
inline void sort(_Tp &x, _Tp &y) {
    if (x > y) std::swap(x, y);
}
template <typename _Tp1, typename _Tp2>
inline std::pair<_Tp1, _Tp2> operator+(std::pair<_Tp1, _Tp2> x,
                                       std::pair<_Tp1, _Tp2> y) {
    return x.fir += y.fir, x.sec += y.sec, x;
}
template <typename _Tp>
inline _Tp &operator+=(_Tp &x, _Tp y) {
    return x = x + y;
}
template <typename _Tp>
inline _Tp gcd(_Tp &x, _Tp &y) {
    return std::__gcd(x, y);
}

}  // namespace oct

#endif  // oct code end pre-document

const int C = 26;
const int Cs = C << 1;
const int INF = 1061109567;

int64 solve(int64 a, int64 b);
int64 check(int64 x);
void get(int64 x, int64 &tmp, int64 &ans);

int64 c0, c1, n;
int64 at[Cs];

inline int64 solve(int64 a, int64 b) {
    int64 sum = 1, x, t, i;
    for (i = 1; i <= b; ++i) at[i] = i;
    for (i = 0; i < b; ++i) {
        x = a + b - i;
        for (int64 j = 1; j <= b; j++) {
            t = oct::gcd(at[j], x);
            x /= t;
            at[j] /= t;
        }
        if (x > INF / sum) return INF;
        sum *= x;
    }
    return sum;
}
inline int64 check(int64 x) {
    int64 tmp = x / c0 + x / c1 + 1, i, j;
    if (tmp > n) return 1;
    for (i = 1; i <= C; ++i) {
        for (j = i; j * c0 + i * c1 <= x; ++j) {
            if ((tmp += solve(j, i)) > n) return 1;
        }
        for (j = i + 1; j * c1 + i * c0 <= x; ++j) {
            if ((tmp += solve(j, i)) > n) return 1;
        }
    }
    return 0;
}
inline void get(int64 x, int64 &tmp, int64 &ans) {
    int64 c, i, j;
    tmp = x / c0 + x / c1 + 1;
    ans = ((x / c0) * (x / c0 + 1) * c0 + (x / c1) * (x / c1 + 1) * c1) >> 1;
    for (i = 1; i <= C; ++i) {
        for (j = i; j * c0 + i * c1 <= x; ++j) {
            c = solve(j, i), tmp += c, ans += c * (j * c0 + i * c1);
        }
        for (j = i + 1; j * c1 + i * c0 <= x; ++j) {
            c = solve(j, i), tmp += c, ans += c * (j * c1 + i * c0);
        }
    }
}

int main() {
    oct::sync();
    std::cin >> n >> c0 >> c1, --n;
    if (c0 > c1) std::swap(c0, c1);
    if (!c0) return std::cout << n * c1 << std::endl, 0;
    int64 c, sum, l = 0, r = c1 * 26, mid;
    while (l <= r) {
        mid = (l + r) >> 1;
        check(mid) ? r = mid - 1 : l = mid + 1;
    }
    get(l - 1, c, sum);
    sum += n * c1 + n * l - c * l + n * c0;
    std::cout << sum << std::endl;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

typedef long long ll;
const int N = 20000;
ll c0, c1;
ll n;
ll C[N];

bool check(ll x)
{
	ll cnt = (x / c0) + 1;
	for (int i = 0; i < N; i++)
		C[i] = i + 1;
	for (int i = 1; cnt < n && i * c1 <= x; i++)
	{
		for (int j = 0; cnt < n && j * c0 + i * c1 <= x; j++)
		{
			cnt += C[j];
			if (j > 0)
				C[j] += C[j - 1];
		}
	}
	return cnt >= n;
}

ll solve(ll x)
{
	ll cnt = (x / c0) + 1;
	ll sum = cnt * (cnt - 1) / 2 * c0;
	for (int i = 0; i < N; i++)
		C[i] = i + 1;
	for (int i = 1; i * c1 <= x; i++)
	{
		for (int j = 0; j * c0 + i * c1 <= x; j++)
		{
			cnt += C[j];
			sum += C[j] * (j * c0 + i * c1);
			if (j > 0)
				C[j] += C[j - 1];
		}
	}
	return sum - (cnt - n) * x;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%lld%lld%lld", &n, &c0, &c1);
	if (c0 > c1) swap(c0, c1);
	n--;
	ll ans = n * (c0 + c1);
	if (n == 1 || c0 == 0)
	{
		printf("%lld\n", ans);
		return 0;
	}
	ll l = 0, r = c0 * n;
	while(r - l > 1)
	{
		ll x = (l + r) / 2;
		if (check(x))
			r = x;
		else
			l = x;
	}
	ans += solve(r);
	printf("%lld\n", ans);

	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int n;
long long c[2];
map<long long, int> ways;

int main() {
	ways.clear();
	cin >> n >> c[0] >> c[1];
	if (c[0] > c[1]) swap(c[0], c[1]);
	if (n == 1) {
		cout << c[0] << endl;
		return 0;
	}

	if (c[0] == 0) {
		cout << c[1] * (long long)(n - 1) << endl;
		return 0;
	}

	ways[c[0]] = 1;
	if (c[0] == c[1]) ways[c[0]] = 2; else ways[c[1]] = 1;
	n -= 2;

	long long ans = c[0] + c[1];
	while (n > 0) {
		map<long long, int>::iterator low = ways.lower_bound(1LL);
		long long cost = low->first;
		int num = low->second;
		ways.erase(low);

		if (n <= num) {
			ans += (long long)n * (cost + c[0] + c[1]);
			break;
		} else {
			long long left = cost + c[0];
			if (ways.find(left) == ways.end()) {
				ways[left] = num;
			} else ways[left] += num;

			long long right = cost + c[1];
			if (ways.find(right) == ways.end()) {
				ways[right] = num;
			} else ways[right] += num;

			n -= num;
			ans += (long long)num * (cost + c[0] + c[1]);
		}
	}
	cout << ans << endl;
	return 0;
}

// vvvvvvvvvvvvvvvvv Library code start

#include <type_traits>

#include <algorithm>
#include <cassert>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>

using namespace std;

/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);

#define ENABLE_IF(e) typename enable_if<e>::type* = nullptr

namespace template_util {

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    /// caide keep
    template<int N>
    struct bytetype {

    };

    /// caide keep
    template<>
    struct bytetype<4> {

    };

    /// caide keep
    template<>
    struct bytetype<3> {

    };

    /// caide keep
    template<>
    struct bytetype<2> {

    };

    /// caide keep
    template<>
    struct bytetype<1> {

    };

    /// caide keep
    template<>
    struct bytetype<0> {

    };

    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}

template<class T, class F, class... Args, ENABLE_IF(is_integral<T>::value)>
inline T bs01(T l, T r, F pred, Args... args) {
    assert(!pred(l, args...) && pred(r, args...));
    while (l + 1 < r) {
        //TODO overflow
        T mid = (l + r) / 2;
        if (pred(mid, args...)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    return r;
}

template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

// ^^^^^^^^^^^^^^^^^ Library code end

void solve(istream& in, ostream& out) {
    int n = next<int>(in);
    int64_t c0 = next<int64_t>(in);
    int64_t c1 = next<int64_t>(in);
    if (c0 > c1) {
        swap(c0, c1);
    }
    if (c0 == 0) {
        out << (n - 1) * c1;
        return;
    }
    auto f = [&](int64_t k) {
        int64_t cnt = 0, sumVals = 0;
        for (int i = 0; c1 * i <= k && cnt < n; ++i) {
            int64_t maxj = (k - c1 * i) / c0;
            if (i == 0) {
                cnt += maxj + 1;
                sumVals += (maxj * c0) * (maxj + 1) / 2;
            } else {
                int64_t c = 1;
                for (int j = 0; c1 * i + c0 * j <= k && cnt < n; ++j) {
                    cnt += c;
                    sumVals += c * (c1 * i + c0 * j);
                    c = c * (i + j + 1) / (j + 1);
                }
            }
        }
        return make_pair(cnt, sumVals);
    };
    int64_t lastVal = bs01(0LL, 1000000000000000000LL, [&](int64_t k) { return f(k).first >= n; });
    auto tmp = f(lastVal - 1);
    out << tmp.second + lastVal * (n - 1 - tmp.first) + (n - 1) * (c0 + c1);
}

int main() {
    solve(cin, cout);
    return 0;
}

#include <bits/stdc++.h>

#define ll long long
#define uint unsigned

#define debug(...) fprintf(stderr, __VA_ARGS__)

#define SZ(x) ((int)(x).size())
#define pb push_back

#define pii std::pair<int,int>
#define mp std::make_pair
#define fi first
#define se second

template<class T>inline void chkmax(T &x, const T &y) {if(x < y) x = y;}
template<class T>inline void chkmin(T &x, const T &y) {if(y < x) x = y;}

template<class T>
inline void read(T &x) {
	char c;int f = 1;x = 0;
	while(((c = getchar()) < '0' || c > '9') && c != '-');
	if(c == '-') f = -1;else x = c - '0';
	while((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
	x *= f;
}

const ll INF = 1e18;

ll n, c0, c1;

ll comb(ll n, ll m) {
	ll ret = 1;
	for(ll i = 0; i < m; ++i)
		ret = ret * (n - i) / (i + 1);
	return ret;
}

ll calc(ll C) {
	ll ret = 0;
	for(ll i = 0; (1 << i) <= n; ++i) {
		if(i * c1 > C) break;
		ll j = (C - i * c1) / c0;
		ret += comb(i + j + 1, i + 1);
	}
	return ret;
}

ll sum(ll C) {
	ll ret = 0;
	for(ll i = 0; (1 << i) <= n; ++i) {
		if(i * c1 > C) break;
		ll j = (C - i * c1) / c0;
		ret += c0 * (i + 1) * comb(i + j + 1, i + 2) + c1 * i * comb(i + j + 1, i + 1);
	}
	return ret;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("B.in", "r", stdin);
	freopen("B.out", "w", stdout);
#endif

	read(n), read(c0), read(c1);
	if(c0 > c1) std::swap(c0, c1);
	if(!c0) printf("%lld\n", c1 * (n - 1));
	else {
		ll l = 0, r = 1;
		while(calc(r) < n - 1) r <<= 1;
		while(l < r) {
			ll mid = (l + r) >> 1;
			if(calc(mid) >= n - 1) r = mid;
			else l = mid + 1;
		}
		std::cout << (n - 1) * (c0 + c1) + (n - 1 - calc(r - 1)) * r + sum(r - 1) << std::endl;
	}

#ifndef ONLINE_JUDGE
	fclose(stdin);fclose(stdout);
#endif
	return 0;
}

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x, y) memset(x, y, sizeof(x))
#define MC(x, y) memcpy(x, y, sizeof(x))
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b > a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b < a)a = b; }
const int N = 0, M = 0, Z = 1e9 + 7, inf = 0x3f3f3f3f;
template <class T1, class T2>inline void gadd(T1 &a, T2 b) { a = (a + b) % Z; }
int n, c0, c1;
map<LL, int>f;
int main()
{
	while (~scanf("%d%d%d", &n, &c0, &c1))
	{
		if (c0 == 0 || c1 == 0)
		{
			LL ans = (n - 1ll) * (c0 + c1);
			printf("%lld\n", ans);
			continue;
		}
		f[0] = 1; --n;
		while (1)
		{
			auto it = f.begin();
 			LL cost = it->first;
			int num = it->second;
			int need = min(n, num);
			f[cost] -= need; if (f[cost] == 0)f.erase(cost);
			f[cost + c0] += need;
			f[cost + c1] += need;
			n -= need; if (n == 0)break;
		}
		LL ans = 0;
		for (auto it : f)
		{
			ans += it.first * it.second;
		}
		printf("%lld\n", ans);
	}
	return 0;
}
/*
【trick&&吐槽】
这种做法会在c0或c1含有0的时候TLE

【题意】
把n（1e8）个字符编码为01串
每一个bit0的编码成本为c0
每一个bit1的编码成本为c1
想使得编码总成本最小的条件下，对所有字符完成编码，且任意一个字符编码不是另外一个的前缀

【分析】

【时间复杂度&&优化】

*/

#include <cstdio>
#include <algorithm>
long long N, c0, c1;
long long gcd(long long x, long long y)
{
	long long r;
	while (y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
long long C(long long x, long long y)
{
	static long long d[100];
	for (int i = 1; i <= y; i++)
		d[i] = x + i;
	for (int i = 1; i <= y; i++)
	{
		int t = i;
		for (int j = 1; t > 1 && j <= y; j++)
		{
			int g = gcd(t, d[j]);
			t /= g;
			d[j] /= g;
		}
	}
	long long T = 1;
	for (int i = 1; i <= y; i++)
		T *= d[i];
	return T;
}
bool check(long long x)
{
	long long tmp = x / c0 + x / c1 + 1;
	if (tmp > N)
		return 1;
	for (int i = 1; i <= 26; i++)
	{
		for (long long j = i; i * c0 + j * c1 <= x; j++)
			if ((tmp += C(j, i)) > N)
				return 1;
		for (long long j = i + 1; j * c0 + i * c1 <= x; j++)
			if ((tmp += C(j, i)) > N)
				return 1;
	}
	return 0;
}
void work(long long x, long long &cnt, long long &sum)
{
	cnt = x / c0 + x / c1 + 1;
	sum = (x / c0) * (x / c0 + 1) * c0 + (x / c1) * (x / c1 + 1) * c1 >> 1;
	long long T;
	for (int i = 1; i <= 26; i++)
	{
		for (long long j = i; i * c0 + j * c1 <= x; j++)
		{
			T = C(j, i);
			cnt += T;
			sum += T * (i * c0 + j * c1);
		}
		for (long long j = i + 1; j * c0 + i * c1 <= x; j++)
		{
			T = C(j, i);
			cnt += T;
			sum += T * (j * c0 + i * c1);
		}
	}
}
int main()
{
	scanf("%lld%lld%lld", &N, &c0, &c1);
	N--;
	if (c0 > c1)
		std::swap(c0, c1);
	if (c0 == 0)
	{
		printf("%lld\n", N * c1);
		return 0;
	}
	long long l = 0, r = c1 * 26;
	while (l < r)
	{
		long long m = l + r >> 1;
		if (check(m))
			r = m;
		else
			l = m + 1;
	}
	long long cnt, sum;
	work(l - 1, cnt, sum);
	printf("%lld\n", (N - cnt) * l + sum + N * (c0 + c1));
	return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#define PB push_back
#define ll long long
#define inf 0x3f3f3f3f3f3f3f3fll
#define fill(a,b) memset(a,b,sizeof(b))
#define cpy(a,b) memcpy(a,b,sizeof(b))
template<typename T> inline bool MIN(T &a,const T &b) {return a>b? a=b,1:0;}
template<typename T> inline bool MAX(T &a,const T &b) {return a<b? a=b,1:0;}

using namespace std;
ll n,c0,c1;

ll C[20000][40];

ll calc(ll j,ll i) {
	if (i==0) return j+1;
	if (j>15000) return n;
	return C[i+j+1][i+1];
}

int ok(ll cost) {
	if (!c0) return 1;
	ll res=0;

	for (ll i=0;i<40&&cost-i*c1>=0;++i) {
		ll j=(cost-i*c1)/c0;
		res+=calc(j,i);
		if (res>=n) return 1;
	}
	return 0;
}

int main()
{
//	freopen("B.in","r",stdin);
//	freopen("B.out","w",stdout);
	scanf("%I64d%I64d%I64d",&n,&c0,&c1); --n;
	if (c0>c1) swap(c0,c1);
	C[0][0]=1;
	for (int i=1;i<20000;++i) {
		C[i][0]=1;
		for (int j=1;j<40;++j) C[i][j]=min(n,C[i-1][j-1]+C[i-1][j]);
	}

	ll l=0,r=inf;
	while (l<r) {
		ll mid=l+r>>1;
		if (ok(mid)) r=mid;
		else l=mid+1;
	}

	ll cnt=0,sum=0;
	for (ll i=0;i<40&&(l-1)-i*c1>=0;++i) {
		ll j=((l-1)-i*c1)/c0;
		if (i==0) {
			cnt+=j+1;
			sum+=(j+1)*j/2*c0;
		} else {
			for (;j>=0;--j) {
//				printf("%I64d %I64d\n",i,j);
				cnt+=C[i+j][i];
				sum+=C[i+j][i]*(c1*i+c0*j);
			}
		}
	}
//	cout<<l<<endl;
	printf("%I64d\n",sum+l*(n-cnt)+n*(c0+c1));
	return 0;
}

//============================================================================
// Author       : Sun YaoFeng
//============================================================================

//#pragma 	comment(linker, "/STACK:100240000,100240000")
//#include	<cstdio>
//#include	<cstdlib>
//#include	<cstring>
//#include	<algorithm>

#include	<bits/stdc++.h>

using	namespace	std;

#define DB		double
#define	lf		else if
#define I64		long long
#define	Rd()	(rand()<<15|rand())
#define For(i,a,b)	for(int i=a,lim=b;i<=lim;i++)
#define Rep(i,a,b)	for(int i=a,lim=b;i>=lim;i--)

#define	fi	first
#define se	second
#define MK	make_pair
#define pb	push_back
#define PA	pair<int, int>

//#define	min(a,b)	((a)<(b)?(a):(b))
//#define	max(a,b)	((a)<(b)?(b):(a))

#define	CH	(ch=getchar())
int		IN()	{
		int x= 0, f= 0, ch;
		for	(; CH < '0' || ch > '9';)	f= (ch == '-');
		for	(; ch >= '0' && ch <= '9'; CH)	x= x*10 + ch -'0';
		return	f? -x : x;
}

int		N, C0, C1;

struct	Nod{
		int x, y;

		Nod	operator *	(const Nod&b)	{
			if	(y || b.y)	return	(Nod){0, 1};
			if	(1ll*x*b.x > (1 << 30))	return	(Nod){0, 1};
			return	(Nod){x*b.x, 0};
		}
};

Nod		C(int x, int y)	{
		static	int	rev[105];

		For(i, 1, y)	rev[i]= x - i + 1;
		For(i, 1, y)	{
			int t= i;
			For(k, 1, y)	{
				int g= __gcd(t, rev[k]);
				rev[k]/= g;
				t/= g;
			}
			assert(t == 1);
		}

		Nod	ret= (Nod){1, 0};
		For(i, 1, y)	ret= ret * (Nod){rev[i], 0};

		return	ret;
}

int		Cal(I64 W)	{
		int ret= 0;
		for (int i= 0; ; i++)	{
			if	(W - 1ll*i*C1 < 0)	break;
			if	(((W - 1ll*i*C1) / C0) > (1 << 30))	return	1 << 30;

			int j= (W - 1ll*i*C1) / C0;
			if	(C(i+j+1, i+1).y)	return	1 << 30;

			ret+= C(i+j+1, i+1).x;
			if	(ret > (1 << 30))	return	1 << 30;
		}
		return	ret;
}

I64		CC(int x, int y)	{
		static	int	rev[105];

		For(i, 1, y)	rev[i]= x - i + 1;
		For(i, 1, y)	{
			int t= i;
			For(k, 1, y)	{
				int g= __gcd(t, rev[k]);
				rev[k]/= g;
				t/= g;
			}
			assert(t == 1);
		}

		I64	ret= 1;
		For(i, 1, y)	ret= ret * rev[i];

		return	ret;
}

I64		Work(I64 W)	{
		I64	ret= 0;
		for (int i= 0; ; i++)	{
			if	(W - 1ll*i*C1 < 0)	break;
			int j= (W - 1ll*i*C1) / C0;

			ret+= 1ll*C1*i*CC(i+j+1, i+1);
			ret+= 1ll*C0*(i+1)*CC(i+j+1, i+2);
		}
		return	ret;
}

int		main(int argc, char* argv[]){
		N= IN();
		C0= IN();
		C1= IN();
		if	(C0 > C1)	swap(C0, C1);

		if	(C0 == 0)	{
			cout << 1ll*(N-1)*(C0 + C1) << endl;
			return	0;
		}

		I64 L= 0, R= 1ll << 60;
		for (; L+1 < R; )	{
			I64 Mid= (L + R) >> 1;
			if	(Cal(Mid) <= N-1)	L= Mid;
				else	R= Mid;
		}

		I64	Ans= 1ll*(N-1)*(C0 + C1);
		Ans+= 1ll*(N-1-Cal(L))*(L+1);
		Ans+= Work(L);

		cout << Ans << endl;

		return	0;
}

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
typedef long long LL;

map<LL,int>mp; map<LL,int>::iterator it;
int main()
{
	int n,c0,c1;
	scanf("%d%d%d",&n,&c0,&c1);
	if(c0==0||c1==0){printf("%lld\n",(LL)(n-1)*(c0+c1));return 0;}

	mp[0]=1;int u=n-1;
	it=mp.begin();
	while(1)
	{
		if(u>it->second)
			mp[it->first+c0]+=it->second,mp[it->first+c1]+=it->second;
		else
		{
			mp[it->first+c0]+=u,mp[it->first+c1]+=u;
			it->second-=u;
			break;
		}
		u-=it->second;
		it++;
	}
	LL ans=0;
	for(;it!=mp.end();it++)
		ans+=(it->first)*(it->second);
	printf("%lld\n",ans);

	return 0;
}

#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
typedef struct node
{
    long long int cost;
    long long int amount;
     friend inline bool
    operator<(const node& p, const node& q)
    {
        return (p.cost>q.cost);
    }

}node;
priority_queue<node> heap;
node tmp;
long long int n,c0,c1,sum=0,k;
int main()
{
    scanf("%I64d",&n);
    scanf("%I64d%I64d",&c0,&c1);
    if(c0>c1)
        swap(c0,c1);
        if(c0==0)
            printf("%I64d",(c1*n-c1));
        else
        {

        tmp.cost=c0;
        tmp.amount=1;
    heap.push(tmp);
        tmp.cost=c1;
        tmp.amount=1;
    heap.push(tmp);
    sum=c0+c1;
    n-=2;
    k=0;
    while(n>0)
    {
        if(k==0)
           {
                tmp=heap.top();
                heap.pop();
                k=1;
           }
           else
        if(k==1)
        {
            if(heap.top().cost==tmp.cost && heap.size()!=0)
                {
                    tmp.amount+=heap.top().amount;
                    heap.pop();
                }
                else
                {
                    node smaller_tmp;
                    smaller_tmp.cost=tmp.cost+c0;
                    smaller_tmp.amount=tmp.amount;
                    node larger_tmp;
                    larger_tmp.cost=tmp.cost+c1;
                    larger_tmp.amount=tmp.amount;
                    if(tmp.amount>=n)
                    {
                        sum+=(n*(tmp.cost+c0+c1));
                        break;
                    }
                    else
                    {
                        heap.push(smaller_tmp);
                        heap.push(larger_tmp);
                        n-=tmp.amount;
                        sum+=(tmp.amount*(tmp.cost+c0+c1));
                        k=0;
                    }
                }
        }
    }
    printf("%I64d",sum);
        }
}

//============================================================================
// Name        : contest.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
#include <tuple>
using namespace std;

#ifdef TEAM
#define dbg2(x, y) cout << #x" = " << x << "; " << #y" = " << y << endl;
#define dbg(x) cout << #x" = " << x << endl;
#else
#define dbg2(...) void(0);
#define dbg(...) void(0);
#endif

#define ALL(v) (v).begin(), (v).end()

typedef long long int llint;
typedef pair<int, int> pii;
void solve();

int main() {
#define FILENAME "division"
#ifdef TEAM
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen(FILENAME".in", "r", stdin);
	//freopen(FILENAME".out", "w", stdout);
#endif

	solve();

	return 0;
}

void solve(){
	int n; cin >> n;
	llint c[2]; cin >> c[0] >> c[1];
	if (c[0] > c[1]) swap(c[0], c[1]);
	if (c[0] == 0){
		cout << (n-1) * c[1];
		return;
	}
	map<llint, int> path;
	path[c[0]] += 1;
	path[c[1]] += 1;
	int sum = 2;
	while (sum < n){
		llint cost; int cnt;
		tie(cost, cnt) = *path.begin();
		dbg2(cost, cnt);
		dbg(sum);
		path.erase(path.begin());
		int add = min(cnt, n - sum);
		path[cost+c[0]] += add;
		path[cost+c[1]] += add;
		if (add < cnt){
			path[cost] = cnt - add;
		}
		sum += add;
	}
	cout << accumulate(ALL(path), 0LL, [](llint x, pair<llint, int> p){
		return x + p.first * p.second;
	});
}

#include <bits/stdc++.h>
#define intl long long
using namespace std;

map<intl,intl> st;

typedef map<intl,intl> :: iterator poi;

intl ans,a,b;
int n;
const intl base = 20000LL;

int main() {
	cin >> n >> a >> b;
	st[0] = 1; n--;
	if (a > b) swap(a, b);
	if (!a) {
		cout << b * (intl) (n) << endl;
		return 0;
	}
	if (a * base < b) {
		for (int t = 0; n; t++) {
			intl N = (b / a) + 1;
			N = min(N, (intl) n);
			ans += N * (N - 1) / 2LL * a + N * b * (intl) t;
			ans += N * (a + b);
			n -= N;
		}
	}
	else while (n > 0) {
		poi q = st.begin();
		intl A = q -> first, B = q -> second;
		ans += min((intl) n, B) * (A + (intl) (a + b));
		n -= B;
   		st.erase(q);
		//cout << q -> first << " " << q -> second << endl;
		st[A + (intl) a] += B;
		st[A + (intl) b] += B;
	}
	cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

void solve() {
	int n, c[2]; cin >> n >> c[0] >> c[1];
	sort(c, c + 2);
	if (c[0] == 0) {
		cout << (long long) (n - 1) * c[1] << "\n";
		return;
	}
	map<long long, int> hs;
	hs[c[0]]++, hs[c[1]]++;
	long long ans = c[0] + c[1];
	int tot = 2;
	while (tot < n) {
		pair<long long, int> x = *hs.begin();
		hs.erase(x.fi);
		hs[x.fi + c[0]] += x.se;
		int tmp = min(n - tot, x.se);
		hs[x.fi + c[1]] += tmp;
		ans += tmp * (x.fi + c[0] + c[1]);
		tot += tmp;
	}
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

#include<cstdio>
#include<cmath>
#define ll long long
const int S=2e4;
int n,m,s,a,b,c[S];ll l,r,ans;
bool check(ll m){
	int sum=m/a,i,j;
	for (i=0;i<=s;i++) c[i]=i+1;
	for (i=1;(ll)i*b<=m&&sum<n;i++)
		for (j=0;(ll)i*b+(ll)j*a<=m&&sum<n;j++){
			sum+=c[j];if (j) c[j]+=c[j-1];
		}
	return sum>=n;
}
void slove(ll m){
	int sum=m/a,i,j;
	ans+=(ll)sum*(sum+1)/2*a;
	for (i=0;i<=s;i++) c[i]=i+1;
	for (i=1;(ll)i*b<=m;i++)
		for (j=0;(ll)i*b+(ll)j*a<=m;j++){
			sum+=c[j];ans+=c[j]*((ll)i*b+(ll)j*a);
			if (j) c[j]+=c[j-1];
		}
	ans-=m*(sum-n);
}
int main(){
	scanf("%d%d%d",&n,&a,&b);
	if (a>b) a^=b,b^=a,a^=b;
	n--;ans+=(ll)n*(a+b);
	n--;s=sqrt(n*2)+1;
	if (!a){printf("%I64d",ans);return 0;}
	for (r=(ll)n*a;l<r;){ll m=l+r>>1;
		if (check(m)) r=m; else l=m+1;
	}
	slove(l);
	printf("%I64d",ans);
}

#include <bits/stdc++.h>
using namespace std;

int n, c0, c1;

long long calc(long long x, long long bound) {
	long long cnt = 0;

	for (int i = 0; ; ++i) {
		long long now = x - 1LL * i * c1;
		if (now < 0) break;
		long long cur = 1;
		for (int j = 0; ; ++j) {
			long long now = 1LL * i * c1 + 1LL * j * c0;
			if (now > x) break;
			cnt += cur;
			if (cnt >= bound) return bound;
			cur *= (i + j + 1);
			cur /= (j + 1);
		}
	}

	return cnt;
}

long long sum(long long x) {
	long long s = 0;

	for (int i = 0; ; ++i) {
		long long now = x - 1LL * i * c1;
		if (now < 0) break;
		long long cur = 1;
		for (int j = 0; ; ++j) {
			long long now = 1LL * i * c1 + 1LL * j * c0;
			if (now > x) break;
			s += cur * now;
			cur *= (i + j + 1);
			cur /= (j + 1);
		}
	}

	return s;
}

int main() {
	cin >> n >> c0 >> c1;
	if (c0 > c1) swap(c0, c1);
	if (c0 == 0) {
		cout << 1LL * (n - 1) * c1 << endl;
		return 0;
	}
	long long l, r;

	l = 0, r = 1LL * c1 * 100;
	while (r - l > 1) {
		long long m = (l + r) / 2;
		if (calc(m, n - 1) == n - 1) r = m; else l = m;
	}

	long long result = 1LL * (c0 + c1) * (n - 1);
	result += r * (n - 1 - calc(r - 1, n - 1));
	result += sum(r - 1);

	cout << result << endl;
	return 0;
}

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<bitset>

using namespace std;
typedef long long LL;
LL ans,a,b;
int n;
map<LL,LL> S;
map<LL,LL>::iterator it;
int main()
{
	cin>>n>>a>>b;
	S[0]=1;
	n--;
	if (a>b) swap(a,b);
	if (a==0)
	{
		cout<<b*(LL)n<<endl;
		return 0;
	}
	if (a*20000LL<b)
	{
		for (int i=0;n;i++)
		{
			LL x=(b/a)+1;
			x=min(x,(LL)n);
			ans+=x*(x-1)/2LL*a+x*b*(LL)i;
			ans+=x*(a+b);
			n-=x;
		}
	}
	else
	{
		while (n>0)
		{
			it=S.begin();
			LL A=it->first,B=it->second;
			ans+=min((LL)n,B)*(A+(LL)(a+b));
			n-=B;
			S.erase(it);
			S[A+(LL)a]+=B;
			S[A+(LL)b]+=B;
		}
	}
	cout<<ans<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int n, c0, c1;

long long calc(long long x, long long bound) {
	long long cnt = 0;

	for (int i = 0; ; ++i) {
		long long now = x - 1LL * i * c1;
		if (now < 0) break;
		if (i == 0) {
			cnt += (now / c0 + 1);
			if (cnt >= bound) return bound;
			continue;
		}
		long long cur = 1;
		for (int j = 0; ; ++j) {
			long long now = 1LL * i * c1 + 1LL * j * c0;
			if (now > x) break;
			cnt += cur;
			if (cnt >= bound) return bound;
			cur *= (i + j + 1);
			cur /= (j + 1);
		}
	}

	return cnt;
}

long long sum(long long x) {
	long long s = 0;

	for (int i = 0; ; ++i) {
		long long now = x - 1LL * i * c1;
		if (now < 0) break;
		if (i == 0) {
			long long c = now / c0;
			s += ((2*c0 + (c-1)*c0)*c)/2;
			continue;
		}
		long long cur = 1;
		for (int j = 0; ; ++j) {
			long long now = 1LL * i * c1 + 1LL * j * c0;
			if (now > x) break;
			s += cur * now;
			cur *= (i + j + 1);
			cur /= (j + 1);
		}
	}

	return s;
}

int main() {
	cin >> n >> c0 >> c1;
	if (c0 > c1) swap(c0, c1);
	if (c0 == 0) {
		cout << 1LL * (n - 1) * c1 << endl;
		return 0;
	}
	long long l, r;

	l = 0, r = 1LL * c1 * 100;
	while (r - l > 1) {
		long long m = (l + r) / 2;
		if (calc(m, n - 1) == n - 1) r = m; else l = m;
	}

	long long result = 1LL * (c0 + c1) * (n - 1);
	result += r * (n - 1 - calc(r - 1, n - 1));
	result += sum(r - 1);

	cout << result << endl;
	return 0;
}

#include <bits/stdc++.h>

#if (_WIN32 || __WIN32__)
#  define LLD "%I64d"
#else
#  define LLD "%lld"
#endif

using std::istream; using std::ostream; using std::fixed; using std::greater;
using std::tuple; using std::tie; using std::make_pair; using std::multiset;
using std::nth_element; using std::min_element; using std::max_element;
using std::vector; using std::set; using std::map; using std::string;
using std::fill; using std::copy; using std::sort; using std::unique;
using std::unordered_set; using std::unordered_map; using std::pair;
using std::next_permutation; using std::reverse; using std::rotate;
using std::cin; using std::cout; using std::cerr; using std::endl;
using std::lower_bound; using std::upper_bound; using std::deque;
using std::min; using std::max; using std::swap; using std::abs;
using std::priority_queue; using std::queue; using std::bitset;
using std::make_tuple; using std::iota;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;

int const INF = 100 + (int) 1e9;
ll const INFL = 100 + (ll) 1e18;
ld const PI = 3.1415926535897932384626433832795028;
std::mt19937 mt19937(960172);

ll rnd(ll x, ll y) { static auto gen = std::bind(std::uniform_int_distribution<ll>(), mt19937); return gen() % (y - x + 1) + x; }
ll gcd(ll a, ll b) { while (b > 0) { ll t = a % b; a = b; b = t; } return a; }
ll sqr(int a) { return (ll) a * a; } ld sqr(ld a) { return a * a; }

void solve() {

    ll n, c0, c1;
    cin >> n >> c0 >> c1;

    if (c0 == 0 || c1 == 0) {
        cout << (ll) (n - 1) * (c0 + c1) << endl;
        return;
    }

    map<ll, ll> f;
    f[0] = 1;

    ll cnt = 1;
    ll cost = 0;

    ll steps = 0;

    while (cnt < n) {
        ++steps;
        ll len = f.begin()->first;
        ll tw = min(n - cnt, f[len]);
        cnt += tw;
        cost += tw * (len + c0 + c1);
        f.erase(len);
        f[len + c0] += tw;
        f[len + c1] += tw;
    }

//    cerr << "steps " << steps << endl;

    cout << cost << endl;
}

int main() {

    cout.precision(15);
    cout << fixed;
    cerr.precision(6);
    cerr << fixed;

    solve();

#ifdef LOCAL
    cerr << "time: " << (ll) clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
}

#include <bits/stdc++.h>

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    int c0, c1;
    cin >> n;
    cin >> c0 >> c1;
    deque<pair<int64_t, int> > ends_0;
    deque<pair<int64_t, int> > ends_1;

    if (c0 > c1)
      swap(c0, c1);
    if (c0 == 0) {
      cout << int64_t(n-1)*c1 << '\n';
      return 0;
    }

    ends_0.push_back({c0, 1});
    ends_1.push_back({c1, 1});
    int64_t total = c0 + c1;

    auto add = [](int64_t cost, int cnt, deque<pair<int64_t, int> >& v) {
      if (!v.empty() && v.back().first == cost) {
	v.back().second += cnt;
      } else {
	v.emplace_back(cost, cnt);
      }
    };

    int have = 2;
    while (have < n) {
      int64_t cost;
      int cnt;
      if (ends_0.front().first < ends_1.front().first) {
	tie(cost, cnt) = ends_0.front();
	ends_0.pop_front();
      } else {
	tie(cost, cnt) = ends_1.front();
	ends_1.pop_front();
      }

      add(cost+c0, cnt, ends_0);
      int add_1 = min(n, have+cnt) - have;
      have += add_1;
      total += add_1*(cost + c0 + c1);
      add(cost+c1, add_1, ends_1);
    }
    cout << total << "\n";
}

#include<bits/stdc++.h>
using namespace std;
int main ()
{
    long long  n, m, r, a, b, k;
    cin >> n >> a >> b;
    if(min(a, b) == 0)
	{
        long long res = max(a, b) * (n - 1);
		cout << res << "\n";
		return 0;
	}
    map < long long, long long > mp;
    mp[0] = 1;
    n--;
    while (n){
        long long cost = mp.begin() -> first;
        long long  cnt = mp.begin() -> second;
        if (cnt <= n)
            mp.erase(mp.begin());
        else
            mp[cost] -= n;
        int erased = min ((long long )n, cnt);
        mp[a+cost]+= erased;
        mp[b+cost]+= erased;
        n -= erased;
    }
    long long ans = 0;
    for(auto it : mp)
        ans += it.first * it.second;
    cout << ans ;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

map < LL, LL > M;

int main()
{
	ios_base::sync_with_stdio(0);
	LL n, a, b;
	cin >> n >> a >> b;
	if(min(a, b) == 0)
	{
		LL res = max(a, b) * (n - 1);
		cout << res << "\n";
		return 0;
	}
	M[0] = 1; n--;
	while(n > 0)
	{
		auto x = *M.begin();
		if(x.second <= n)
		{
			n -= x.second;
			M.erase(M.begin());
			M[x.first + a] += x.second;
			M[x.first + b] += x.second;
		}
		else
		{
			M[x.first] -= n;
			M[x.first + a] += n;
			M[x.first + b] += n;
			n = 0;
		}
	}
	LL ans = 0;
	for(auto x: M)
		ans += x.second * x.first;
	cout << ans << "\n";
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
const long long CON = 3e4;
long long n, c0, c1;
struct node {
	long long a, b, c;
	node(long long a = 0, long long b = 0) : a(a), b(b) {c = a * c0 + b * c1;}
};
bool operator < (const node &a, const node &b) {
	if (a.c != b.c) return a.c < b.c;
	if (a.a != b.a) return a.a < b.a;
	return a.b < b.b;
}
int main() {
	cin >> n >> c0 >> c1;
	if (c0 > c1) swap(c0, c1);
	if (c0 == 0) {
		cout << (n - 1) * c1 << endl;
		return 0;
	}
	long long ans = 0;
	if (c0 * CON <= c1) {
		long long len = c0 / c1 + 1;
		ans += (len - 1) * len / 2 + (len - 1) * (c0 + c1);
		n -= len + 1;
		for (long long a = 1; n; ++ a) {
			long long take = min(n, a);
			n -= take;
			ans += take * (a * c0 + c1 + c0 + c1);
		}
	}
	else {
		map<node, long long> que;
		-- n;
		++ que[node(0, 0)];
		while (n) {
			auto x = *que.begin();
			que.erase(que.begin());
			long long take = min(x.second, n);
			ans += take * (x.first.c + c0 + c1);
			que[node(x.first.a + 1, x.first.b)] += take;
			que[node(x.first.a, x.first.b + 1)] += take;
			n -= take;
		}
	}
	cout << ans << endl;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second
#define int ll

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
set<PR> Set;
int n,c0,c1,num,ans;
void add(int x,int y)
{
	set<PR>::iterator it=Set.lower_bound(MP(x,0));
	if (it!=Set.end()&&(*it).fi==x) y+=(*it).se,Set.erase(it);
	Set.insert(MP(x,y));
}
signed main()
{
	n=read(),c0=read(),c1=read();
	if (c0>c1) swap(c0,c1);
	if (!c1) { puts("0"); return 0; }
	if (!c0) { printf("%lld\n",1ll*(n-1)*c1); return 0; }
	Set.insert(MP(0,1)),num=1,ans=0;
	while (num<n)
	{
		int x=(*Set.begin()).fi,y=(*Set.begin()).se;
		Set.erase(Set.begin());
		upmin(y,n-num);
		num+=y,ans+=(x+c0+c1)*y;
		add(x+c0,y),add(x+c1,y);
	}
	printf("%lld\n",ans);
	return 0;
}

#include <bits/stdc++.h>

#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define for1(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define clr(x) memset((x), 0, sizeof((x)));
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long i64;
typedef unsigned long long ull;

template<class T>
bool remin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool remax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

ll gcd(ll a, ll b) {
    a = abs(a);
    b = abs(b);
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

typedef ll ptdata;

struct pt {
    ptdata x, y;

    pt() {}

    pt(ptdata x, ptdata y) : x(x), y(y) {}

    inline pt operator-(const pt &r) const {
        return pt(x - r.x, y - r.y);
    }

    inline pt operator+(const pt &r) const {
        return pt(x + r.x, y + r.y);
    }

    inline pt operator*(const ld &r) const {
        return pt(x * r, y * r);
    }

    inline ptdata sqlen() const {
        return abs(x * x + y * y);
    }

    inline bool operator<(const pt &r) const {
        if (x != r.x) return x < r.x;
        return y < r.y;
    }

    inline bool operator==(const pt &r) const {
        return x == r.x && y == r.y;
    }
};

ostream &operator<<(ostream &os, const pt &p) {
    return os << "(" << p.x << "," << p.y << ")";
}

inline ptdata cross(const pt &l, const pt &r) {
    return l.x * r.y - l.y * r.x;
}

inline ptdata dot(const pt &l, const pt &r) {
    return l.x * r.x + l.y * r.y;
}

ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

template<typename T>
inline T sqr(T x) {
    return x * x;
}

const int N = 1000 * 1000;
const ll inf = LLONG_MAX >> 1;
struct Q {
    ll q[N];
    ll sum = 0;
    int cnt[N];
    int qs = 0, qsize = 0;
    Q() {}
    inline void add(ll val, int c) {
        sum += c;
        if (empty()) {
            q[qs] = val;
            cnt[qs] = c;
            ++qsize;
            return;
        }
        if (qsize == N) return;
        int ps1 = qs + qsize - 1;
        if (ps1 >= N) ps1 -= N;
        int ps2 = qs + qsize;
        if (ps2 >= N) ps2 -= N;
        if (q[ps1] == val) {
            cnt[ps1] += c;
            return;
        }
        q[ps2] = val;
        cnt[ps2] = c;
        qsize++;
    }
    inline bool empty() const {
        return qsize == 0;
    }
    inline pair<ll, int> min() const {
        if (empty()) return mp(inf, 1);
        return mp(q[qs], cnt[qs]);
    }
    inline pair<ll, int> max() const {
        if (empty()) return mp(-inf, 1);
        int ps1 = qs + qsize - 1;
        if (ps1 >= N) ps1 -= N;
        return mp(q[ps1], cnt[ps1]);
    }
    inline void pop() {
        sum -= cnt[qs];
        ++qs;
        --qsize;
        if (qs == N) qs = 0;
    }
};

Q q[2];

const int MAGIC = 100000;

inline void solve() {
    int n = nxt();
    ll c[2];
    c[0] = nxt();
    c[1] = nxt();
    if (c[0] == 0 || c[1] == 0) {
        ll m = c[0] + c[1];
        cout << (n - 1) * m << "\n";
        return;
    }
    q[0].add(0, 1);

    ll ans = 0;
    pair<ll, int> mi[2];
    pair<ll, int> ma[2];
    --n;
    while (n > 0) {
        forn(j, 2) {
            mi[j] = q[j].min();
            ma[j] = q[j].max();
        }
        int id = 0;
        if (mi[1].first < mi[0].first) id = 1;

        ll k = n;
        if (c[id]) {
            k = (mi[id ^ 1].first - ma[id].first) / c[id];
        }
        remin(k, (n / q[id].sum));

        if (k == 0 || q[id ^ 1].qsize < MAGIC) {
            int cc = min(mi[id].second, n);
            n -= cc;
            ans -= mi[id].first * cc;
            ans += mi[id].first * cc + c[0] * cc;
            ans += mi[id].first * cc + c[1] * cc;
            mi[id].second -= cc;
            if (mi[id].second == 0) {
                q[id].pop();
            }
            q[0].add(mi[id].first + c[0], cc);
            q[1].add(mi[id].first + c[1], cc);
        } else {
//            cerr << k << "\n";
//            cerr << q[id].qsize << "\n";
            vector<pair<ll, int> > w;
            while (!q[id].empty()) {
                w.push_back(q[id].min());
                q[id].pop();
            }
            for (auto pa : w) {
                ans -= pa.first * pa.second;
            }
            for (auto pa : w) {
//                cerr << pa.first * pa.second + k * c[id] * pa.second << "\n";
//                cerr << k * pa.first * pa.second + k * (k - 1) / 2 * c[id] + k * c[id ^ 1] * pa.second << "\n";
                ans += pa.first * pa.second + k * c[id] * pa.second;
                ans += k * pa.first * pa.second + k * (k - 1) / 2 * c[id] + k * c[id ^ 1] * pa.second;
                q[id].add(pa.first + k * c[id], pa.second);
            }
            n -= k * q[id].sum;
        }
    }
    cout << ans << "\n";
}

void prepare() {

}

int main() {
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    prepare();

    int t = 1;
    //t = nxt();
    forn(i, t) {
        solve();
    }
    //14999999850000000
    //195405044762803700
    //9999999999999999
    //100000000 1 100000000
    //20042860182236000
    cerr << "Time " << clock() / (double) CLOCKS_PER_SEC << endl;
    return 0;
}

#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<ctime>
#include<vector>
#include<string>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
using namespace std;
struct pp
{
    long long cost;
    bool operator <(const pp &temp)const
    {
        return cost<temp.cost;
    }
};
map<pp,int>hs;
int n,c[2];
pp now;
map<pp,int> solve(int n)
{
    map<pp,int>ret,ms;
    map<pp,int>::iterator it;
    pp u,now;
    ret.clear();
	if(n<=3)
    {
        now.cost=c[0];
        ret[now]++;
        now.cost=c[1];
        ret[now]++;
    }
    if(n==2)
       return ret;
    if(n>3)
        ret=solve(n/2);
    int nc=0,vl;
   // printf("n=%d,ret.size()=%d\n",n,ret.size());
    while(n>3&&nc<n/2)
    {
        it=ret.begin();
		if(nc+it->second>=n/2)
            vl=n/2-nc;
        else
            vl=it->second;
         u=it->first;
         ret[u]-=vl;
         if(ret[u]==0)
            ret.erase(u);
         nc+=vl;
         now=u;
         now.cost+=c[0];
         ret[now]+=vl;
         now=u;
         now.cost+=c[1];
         ret[now]+=vl;
    }
    if(n&1)
    {
        it=ret.begin();
        u=it->first;
        ret[u]--;
        if(ret[u]==0)
            ret.erase(u);
        now=u;
        now.cost+=c[0];
        ret[now]++;
        now=u;
        now.cost+=c[1];
        ret[now]++;
    }
    return ret;
}
int main()
{
    scanf("%d%d%d",&n,&c[0],&c[1]);
    if(c[0]==0||c[1]==0)
    {
    	printf("%lld\n",(long long)(n-1)*(long long)max(c[0],c[1]));
    	return 0;
    }
	hs=solve(n);
    map<pp,int>::iterator it;
    pp u;
    long long ans=0;
    for(it=hs.begin();it!=hs.end();it++)
    {
         u=it->first;
         ans+=(long long)u.cost*(long long)hs[u];
    }
    printf("%lld\n",ans);
    return 0;
}
/*
100000000 1 3

*/

#include <bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int) (x).size())
#define ALL(x) x.begin(), x.end()

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef unsigned long long u64;
typedef vector<int> VI;

template <typename T> inline bool cmin(T & a, const T & b) { return a > b ? a = b, 1 : 0;}
template <typename T> inline bool cmax(T & a, const T & b) { return a < b ? a = b, 1 : 0;}

int read() {
	int x = 0, f = 1;char ch;
	for (ch = getchar(); !isdigit(ch); ch = getchar())
		if (ch == '-') f = -1;
	for (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return x * f;
}

int main() {
	LL n, c0, c1;
	cin >> n >> c0 >> c1;
	if(!c0 || !c1)
		return printf("%lld\n", (c0 + c1) * (n - 1)), 0;
	map<LL, LL> F;
	for (F[0] = 1, --n; n > 0; ) {
		pair<LL, LL> cur = *F.begin();
		if(cur.se <= n) {
			F.erase(F.begin());
			F[cur.fi + c0] += cur.se;
			F[cur.fi + c1] += cur.se;
		} else {
			F[cur.fi] -= n;
			F[cur.fi + c0] += n;
			F[cur.fi + c1] += n;
		}
		n -= cur.se;
	}
	LL ans = 0;
	for (auto x : F)
		ans += x.fi * x.se;
	cout << ans << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef pair<long long,long long> pii;
long long c0,c1,n;
long long gcd(long long a,long long b){
	if(b) return gcd(b,a%b);
	else return a;
}
long long lyslys[31];
long long cycyc(long long a,long long b){
    long long s=1,x,g,i;
    for(i=1;i<=b;++i) lyslys[i]=i;
    for(i=0;i<b;++i){
        x=a+b-i;
        for(long long j=1;j<=b;j++){
            g=gcd(lyslys[j],x);
            x/=g;
            lyslys[j]/=g;
        }
        if(x>1061109567/s)return 1061109567;
        s*=x;
    }
    return s;
}
long long check(long long x){
    long long tmp=x/c0+x/c1+1;
    if(tmp>n) return 1;
	long long i,j;
    for(i=1;i<=26;++i){
        for(j=i;j*c0+i*c1<=x;++j){
            tmp+=cycyc(j,i);
            if(tmp>n) return 1;
        }
        for(j=i+1;j*c1+i*c0<=x;++j){
            tmp+=cycyc(j,i);
            if(tmp>n) return 1;
        }
    }
    return 0;
}
void keywet(long long x,long long &tmp,long long &ans){
    tmp=x/c0+x/c1+1;
    ans=((x/c0)*(x/c0+1)*c0+(x/c1)*(x/c1+1)*c1)>>1;
    long long c,i,j;
    for(i=1;i<=26;++i){
        for(j=i;j*c0+i*c1<=x;++j){
            c=cycyc(j,i);
            tmp+=c;
            ans+=c*(j*c0+i*c1);
        }
        for(j=i+1;j*c1+i*c0<=x;++j){
            c=cycyc(j,i);
            tmp+=c;
            ans+=c*(j*c1+i*c0);
        }
    }
}
void skc(){
	int a,b,c,d,e;
	a=1;
	b=2;
	c=3;
	d=4;
	e=5;
	b=a+c;
	a=++++++++++++++++++c;
	d=++++a;
	int dblark;
	int AK_IOI;
	dblark=AK_IOI=++++c;
}
int main(){
	skc();
	scanf("%lld%lld%lld",&n,&c0,&c1);
    n--;
    if(c0>c1) swap(c0,c1);
    if(!c0){
		printf("%lld\n",n*c1);
		return 0;
	}
    long long l=0,r=c1*26,mid;
    while(l<=r){
        mid=(l+r)>>1;
        if(check(mid)) r=mid-1;
        else l=mid+1;
    }
    long long c,s;
    keywet(l-1,c,s);
    s+=(n-c)*l+n*(c0+c1);
    printf("%lld\n",s);
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using db = double;
using vi = vector<int>;
#define pb push_back
const ll mod1 = (ll)1e9+9;
const ll mod2 = (ll)1e9+7;

ll n, c0, c1;

ll getmul(ll a, ll k, ll mod) {
	ll ret = 1;
	while (k > 0) {
		if (k & 1) ret = (ret * a) % mod;
		k /= 2;
		a = (a*a) % mod;
	}
	return ret;
}

ll C(ll n, ll m) {
	ll r1 = 1, r2 = 1;
	for (ll i = 1; i <= m; ++i) {
		r1 = (r1 * (n-i+1)) % mod1 * getmul(i,mod1-2,mod1) % mod1;
		r2 = (r2 * (n-i+1)) % mod2 * getmul(i,mod2-2,mod2) % mod2;
	}
	if (r1 != r2) return -1;
	return r1;
}

bool check(ll c) {
	//cout<<c<<endl;
	ll sum = 0;
	for (ll i = 0; i*c0 <= c; ++i) {
		ll j = (c-i*c0)/c1;
		ll tmp = C(i+j+1,i+1);
		//cout<<i<<' '<<j<<' '<<tmp<<endl;
		if (tmp == -1) return true;
		sum += tmp;
		if (sum >= n-1) return true;
	}
	return false;
}

void solve(ll c) {
	//cout<<c<<endl;
	ll ans = 0;
	ll sum = 0;
	for (ll i = 0; i*c0 <= c; ++i) {
		if (i == 0) {
			ll t = c/c1+1;
			ans += ((t-1)*c1)*t/2;
			sum += t;
		}
		else {
			for (ll j = 0; i*c0+j*c1 <= c; ++j) {
				ll t = min(sum, C(i+j,i));
				ans += t*(i*c0+j*c1);
				sum += t;
			}
		}
	}
	cout<<ans-(sum-(n-1))*c+(c0+c1)*(n-1)<<endl;
}

int main() {
	cin>>n>>c0>>c1;
	if (c0*c1 == 0) {
		cout<<ll(n-1)*(c0+c1)<<endl;
		return 0;
	}
	if (c0 < c1) swap(c0, c1);
	ll l = 0, r = c1*n*100;
	while (l + 1 < r) {
		ll m = (l + r) / 2;
		if (check(m)) r = m;
		else l = m;
	}
	solve(r);
}

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ());

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

int n, a, b;

int read() {
  if (scanf("%d%d%d", &n, &a, &b) < 3) {
    return 0;
  }
  return 1;
}

long long res;

long long get(long long p, bool countr = 0) {
  res = 0;
  long long cnt = 0;
  for (int i = 0; p >= 0ll; ++i, p -= b) {
    long long k = a ? p / a : (n + 1);

    long long N = i + 1 + k;
    long long K = min(k, N - k);
    //eprintf("N = %lld, K = %lld\n", N, K);
    long long c = 1;
    for (int j = 1; j <= K; ++j) {
      c *= N - j + 1;
      c /= j;
      if (c > 1e16) {
        break;
      }
    }
    cnt += c;
    if (countr) {
      res += c * b * i;
      if (1 && i == 0) {
        res += (long long) k * (k + 1) / 2 * a;
      } else {
        c = 1;
        for (int j = 1; j <= k; ++j) {
          c *= j + i;
          c /= j;
          res += c * a * j;
        }
      }
    }
  }
  return cnt;
}

void solve() {
  if (a > b) {
    swap(a, b);
  }
  if (!b) {
    printf("0\n");
    return;
  }
  long long left = -1, right = b * 30ll;
  while (left + 1 < right) {
    auto mid = (left + right) / 2;

    if (get(mid) >= n - 1) {
      right = mid;
    } else {
      left = mid;
    }
  }
  auto got = get(right, 1);
  res -= (got - n + 1) * right;
  res += (long long) (a + b) * (n - 1);
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

int n;
ll c0,c1;

ll get_c(ll m,ll n)
{
	ll v = 1;
	for(int i = 1;i <= n;i ++) v = v * (m - i + 1) / i;
	return v;
}

ll calc(ll c)
{
	if (c < 0) return 0;
	ll tmp = 0;
	for(int i = 0;(1ll << i) <= n;i ++)
	{
		if (c - c1 * i < 0) break;
		ll mx;
		if (c0) mx = (c - c1 * i) / c0; else return n;
		tmp += get_c(i + mx + 1,i + 1);
		if (tmp >= n) return tmp;
	}
	return tmp;
}

int main()
{
	scanf("%d%lld%lld", &n, &c0, &c1);
	if (c0 > c1) swap(c0,c1);
	n --;
	ll l = 0,r = 1,tmp;
	for(;calc(r) < n;r <<= 1);
	for(ll mid;l <= r;)
	{
		mid = l + r >> 1;
		if (calc(mid) >= n) tmp = mid,r = mid - 1; else l = mid + 1;
	}
	ll extra = n - calc(tmp - 1);
	ll ans = tmp * extra + n * (c0 + c1);
	tmp --;
	if (c1 && tmp >= 0)
	{
		ll mx = tmp / c1;
		for(int i = 0;i <= mx;i ++)
			ans += c1 * i * get_c(i + (tmp - c1 * i) / c0 + 1,i + 1);
		for(int i = 0;i <= mx;i ++)
			ans += c0 * (i + 1) * get_c(i + (tmp - c1 * i) / c0 + 1,i + 2);
	}
	printf("%lld\n", ans);
	return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const ll inf=1000000000000000000ll;
ll gcd(ll x,ll y)
{
	return y==0?x:gcd(y,x%y);
}
ll c1,c2,n,pp,re,sp;
ll c(ll x,ll y)
{
	if (x-y<y) y=x-y;
	if (y<=0) return 1;
	if (y==1) return x;
	ll re=1;
	fo(i,1,y)
	{
		ll g=gcd(re,i),tp=(x-y+i);
		re/=g; tp/=(i/g);
		re=re*tp;
		if (re%tp || re<=0 || re>n) return inf;
	}
	return re;
}
bool check(ll mid)
{
	pp=0; re=0; ll up=mid/c2;
	ll last=-1;
	pp=0;ll calc=0;
	fd(l,up,0)
	{
		ll num=(mid-l*c2)/c1;
		if (l==0)
		{
			calc=1;
			pp+=calc;
			re+=calc*c1*(last+1);
			if (pp>=n) return 1;
			continue;
		}
		if (l==1 && sp)
		{
			pp+=max(num-last-1,0ll);
			if (pp>=n) return 1;
		} else
		{
			fd(j,num,last+2)
			{
				calc=c(j+l-1,l-1);
				pp+=calc;
				re+=calc*(l*c2+j*c1);
				if (pp>=n) return 1;
			}
		}
		calc=c(l+last+1,last+1);
		pp+=calc;
		re+=calc*(l*c2+(last+1)*c1);
		if (pp>=n) return 1;
		last=num;
	}
	if (pp>=n) return 1;
	return 0;
}
int main()
{
	cin>>n>>c1>>c2;
	if (c1>c2) swap(c1,c2);
	if (c1==0)
	{
		cout<<c2*(n-1);
		return 0;
	}
	ll gp=gcd(c1,c2);
	c1/=gp; c2/=gp;
	ll l=0,r=1000000000000000000ll,ans=0;
	sp=1;
	while (l<=r)
	{
		ll mid=(l+r)/2;
		if (check(mid)) ans=mid,r=mid-1; else l=mid+1;
	}
	sp=0;
	pp=0;
	check(ans-1);
	ll rem=(n-pp);
	re=re+rem*ans+rem*c1;
	cout<<re*gp;
}

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

LL n, a, b;
unsigned long long C[25000][35];

int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n >> a >> b;
    --n;
    if (a > b) {
        swap(a, b);
    }
    if (a == 0) {
        cout << n * (a + b) << endl;
        return 0;
    }
    LL lo = 0, hi = 3e9, mid;
    while (lo < hi) {
        mid = (lo + hi) >> 1;
        LL cnt = 0;
        forn(i, 30) {
            LL rem = mid - b * i;
            if (rem >= 0) {
                LL c = rem / a + 1;
                LL tmp = 1;
                for (int x = 0; x <= i; ++x) {
                    tmp = (tmp * (c + x)) / (x + 1);
                    if (tmp > n) break;
                }
                cnt += min(tmp, n);
            }
        }
        if (cnt >= n) {
            hi = mid;
        } else {
            lo = mid + 1;
        }
    }
    //cerr << lo << endl;

    forn(i, 35) C[0][i] = 0;
    C[0][0] = 1;
    for (int i = 1; i < 25000; ++i) {
        C[i][0] = 1;
        for (int j = 1; j < 35; ++j) {
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }

    LL ans = 0;
    LL cnt = 0;
    LL mx = 0;
    forn(i, 30) {
        LL rem = lo - b * i;
        if (rem >= 0) {
            LL c = rem / a + 1;
            if (i == 0) {
                cnt += c;
                mx = max(mx, a * (c - 1));
                ans += c * (c - 1) / 2 * a;
            } else {
                mx = max(mx, i * b + a * (c - 1));
                for (int j = 0; j < c; ++j) {
                    cnt += C[i + j][i];
                    ans += C[i + j][i] * (i * b + j * a);
                }
            }
        }
    }
    assert(cnt >= n);
    ans -= mx * (cnt - n);
    ans += n * (a + b);
    cout << ans << endl;
    return 0;
}

#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 10000005, M = 1005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int c[M+3][M+3];

ll a, b;

ll con(int x, int y) {
  if (x < M) return c[x][y];
  if (y == 0) return 1;
  if (y == 1) return x;
  if (y == 2) return ll(x-1)*x/2;
  return INF;
}
bool f(ll x, ll n) {
  ll pre = -1;
  for (ll i = x/a; i >= 0; --i) {
    ll j = (x-a*i)/b;
    ll s = con(i+j,j);
    n -= s;
    if (pre != j) n -= s;
    if (n < 0) return false;
    pre = j;
  }
  return true;
}

int cnt;
ll g(ll x) {
  cnt = 0;
  ll res = 0;
  ll pre = -1;
  for (ll i = x/a; i >= 0; --i) {
    ll j = (x-a*i)/b;
    ll s = con(i+j,j);
    ll t = pre!=j?2:1;
    cnt += s*t;
    res += s*((a*i+b*j)*t+b);
    if (pre != j) res += s*a;
    pre = j;
  }
  return res;
}

int main() {
  c[0][0] = 1;
  rep(i,M) {
    rep(j,i+1) c[i+1][j] += c[i][j], c[i+1][j+1] += c[i][j];
    rep(j,i+2) mins(c[i+1][j], INF);
  }
  int n;
  cin >> n >> a >> b;
  if (a > b) swap(a,b);
  if (!a) {
    cout<<b*(n-1)<<endl;
    return 0;
  }
  ll l = 0, r = b*n+1;
  while (l+1<r) {
    ll md = (l+r)>>1;
    if (f(md,n)) l = md; else r = md;
  }
  ll ans = g(l);
  n -= cnt;
  ans += n*(r+a+b);
  cout<<ans<<endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define sz(x) ((long long int)(x).size())
#define pb push_back
#define itn int
#define mp make_pair
#define pii pair<ll, ll>

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, c0, c1;
    cin >> n >> c0 >> c1;
    if (c1 == 0 || c0 == 0)
        return !(cout << (c1 + c0) * (n - 1));
    map <ll, ll> f;
    f[0] = 1;
    --n;
    while (n > 0) {
        pii c = *(f.begin());
        if (c.second <= n) {
            f.erase(f.begin());
            f[c.first + c0] += c.second;
            f[c.first + c1] += c.second;
        }
        else {
            f[c.first] -= n;
            f[c.first + c0] += n;
            f[c.first + c1] += n;
        }
        n -= c.second;
    }
    ll ans = 0;
    for (pii x : f) {
        ans += x.first * x.second;
    }
    cout << ans;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#ifdef ONLINE_JUDGE
#define OJ 1
#else
#define OJ 0
#endif

#define dd				double
#define ll 				long long
#define pb 				push_back
#define mp 				make_pair
#define X				first
#define Y				second
#define forn( i, n ) 	for( ll i = 0; i < (ll) (n); i ++ )
#define endl 			'\n'

#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

struct __s { __s() {
		srand( time( NULL ) );
		//freopen( "input.txt", "r", stdin ); freopen( "output.txt", "w", stdout );
		if( OJ ) { ios_base::Init i; cin.sync_with_stdio( 0 ); cin.tie( 0 ); }
	} ~__s() {
		if( !OJ ) TIMESTAMP;
		ll n; cin >> n;
	}
} __S;

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;
priority_queue< pair< ll, pair< ll, ll > > > q;

void add( ll x, ll y ) {
	if( u.find( mp( x, y ) ) != u.end() )
		return;
	u.insert( mp( x, y ) );
	q.push( mp( -( x * c0 + y * c1 ), mp( x, y ) ) );
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 == 0 || c1 == 0 ) {
		ll ans = ( n - 1 ) * max( c1, c0 );
		cout << ans << endl;
		return 0;
	}
	m[mp( 0, 1 )] ++;
	m[mp( 1, 0 )] ++;
	n -= 2;
	add( 0, 1 );
	add( 1, 0 );
	ll ans = c0 + c1;
	while( n ) {
		ll s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		m[mp( p.X + 1, p.Y )] += m[p];
		m[mp( p.X, p.Y + 1 )] += m[p];
		add( p.X + 1, p.Y );
		add( p.X, p.Y + 1 );
		ll k = min( n, m[p] );
		n -= k;
		ans += 1LL * k * ( s + c0 + c1 );
	}
	cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>
#define int long long

std::map < int, int > M;

signed main()
{
	int n, a, b;
	std::cin >> n >> a >> b;
	if(std::min(a, b) == 0)
	{
		int res = std::max(a, b) * (n - 1);
		std::cout << res << "\n";
		return 0;
	}
	M[0] = 1; n--;
	while(n > 0)
	{
		auto x = *M.begin();
		if(x.second <= n)
		{
			n -= x.second;
			M.erase(M.begin());
			M[x.first + a] += x.second;
			M[x.first + b] += x.second;
		}
		else
		{
			M[x.first] -= n;
			M[x.first + a] += n;
			M[x.first + b] += n;
			n = 0;
		}
	}
	int ans = 0;
	for(auto x: M) ans += x.second * x.first;
	std::cout << ans << "\n";
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

// 错误算法，偏的树会错…
// 不仅算法错了，即便对于不偏的树代码也有些错误(改过来了，不过做法还是错的)
// wocao居然过了…数据也太弱了…乱出的吧…居然没有100000000 1 100000000 这种数据???

const ll MXL = 0x3f3f3f3f3f3f3f3fLL;

ll lim = 100000;
ll n;
ll a, b;

vector<pair<ll,ll>> p; // {index, sum}
multiset<ll> s;

void ini() {
	p = {{0, 0}};
	s = {0};
	for (int i = 0; i < lim || p.back().first - b == *s.begin(); ++i) { // 相同值的情况没考虑
		ll t = *s.begin();
		s.erase(s.begin());
		p.pb({t + b, -t + (t + a) + (t + b)});
		s.insert(t + a);
		s.insert(t + b);
	}
	ll pre = 0;
	for (auto &i : p)
		i.second = pre += i.second;
	//for (auto i : s)
		//cout << i << ' ';
	//cout << endl;
	//for (auto i : p)
		//cout << i.first << ' ' << i.second << endl;
}

ll count(ll deep) {
	if (deep <= p.back().first)
		return upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)) - p.begin();
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		re += upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)) - p.begin();
		re = min(re, MXL);
	}
	return re;
}

ll sum(ll deep) {
	if (deep <= p.back().first)
		return prev(upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)))->second;
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		auto t = prev(upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)));
		re += t->second + ll(t - p.begin() + 1) * i; // 减begin的时候要+1…因为prev过了…
		assert(re < MXL);
	}
	return re;
}

ll getDeep() {
	ll L = 0, R = MXL, M;
	while (L < R)
		if (M = L + R >> 1, count(M) >= n)
			R = M;
		else
			L = M + 1;
	return L;
}

int main() {
	cin >> n >> a >> b;
	if (a > b) swap(a, b);

	// 没判a,b为0的情况…wocao…

	if (a == 0 && b == 0) {
		cout << 0 << endl;
		return 0;
	}

	if (a == 0) {
		cout << (n - 1) * b << endl;
		return 0;
	}

	ini();

	ll h = getDeep();

	//cout << "deep = " << h << endl;
	//cout << "cnt = " << count(h) << endl;

	ll c = count(h);
	ll ans = sum(h);

	//cout << "sum = " << ans << endl;

	if (c > n)
		ans -= (c - n) * (h + (h - b + a) - (h - b));

	cout << ans << endl;

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define ll				long long
#define dd				double
#define X				first
#define Y				second
#define mp				make_pair
#define pb				push_back
#define forn( i, n )	for( ll i = 0; i < (ll) (n); i ++ )
#define endl			'\n'

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;

void add( ll x, ll y, priority_queue< pair< ll, pair< ll, ll > > > &q ) {
	if( u.find( mp( x, y ) ) != u.end() )
		return;
	u.insert( mp( x, y ) );
	q.push( mp( -( x * c0 + y * c1 ), mp( x, y ) ) );
}

ll mod = 1e1;

vector< ll > create( ll x ) {
	vector< ll > res;
	if( x == 0 ) {
		res.pb( 0 );
		return res;
	}
	while( x ) {
		res.pb( x % mod );
		x /= mod;
	}
	return res;
}

vector< ll > mul( vector< ll > v, ll x ) {
	vector< ll > res;
	ll ost = 0;
	forn( i, v.size() ) {
		res.pb( v[i] * x );
		res[i] += ost;
		ost = res[i] / mod;
		res[i] %= mod;
	}
	while( ost ) {
		res.pb( ost % mod );
		ost /= mod;
	}
	return res;
}

vector< ll > sum( vector< ll > a, vector< ll > b ) {
	vector< ll > res;
	ll n = max( a.size(), b.size() );
	ll ost = 0;
	forn( i, n ) {
		res.pb( ost );
		if( i < a.size() )
			res[i] += a[i];
		if( i < b.size() )
			res[i] += b[i];
		ost = res[i] / mod;
		res[i] %= mod;
	}
	while( ost ) {
		res.pb( ost % mod );
		ost /= mod;
	}
	return res;
}

vector< ll > sub( vector< ll > a, vector< ll > b ) {
	vector< ll > res = a;
	forn( i, b.size() ) {
		res[i] -= b[i];
		if( res[i] < 0 ) {
			res[i] += mod;
			if( i + 1 < res.size() )
				res[i + 1] --;
			else
				return mul( create( 1e18 ), 1e8 );
		}
	}
	if( b.size() < res.size() && res[b.size()] < 0 ) {
		res[b.size()] += mod;
		if( b.size() + 1 < res.size() )
			res[b.size() + 1] --;
		else
			return mul( create( 1e18 ), 1e8 );
	}
	return res;
}

bool check( vector< ll > a, vector< ll > b ) {
	while( a.size() < b.size() )
		a.pb( 0 );
	while( a.size() > b.size() )
		b.pb( 0 );
	for( ll i = a.size() - 1; i >= 0; i -- ) {
		if( a[i] == b[i] )
			continue;
		if( a[i] > b[i] )
			return true;
		else
			return false;
	}
}

void write( vector< ll > ans ) {
	bool ok = false;
	forn( ii, ans.size() ) {
		ll i = ans.size() - 1 - ii;
		if( !ok && ans[i] == 0 )
			continue;
		if( ok ) {
			ll m = mod / 10;
			while( m ) {
				ll x = ans[i] / m;
				cout << x;
				ans[i] -= x * m;
				m /= 10;
			}
		} else
			cout << ans[i];
		ok = true;
	}
	if( !ok )
		cout << 0;
	cout << endl;
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 > c1 )
		swap( c0, c1 );
	vector< ll > ans = sum( create( ( n - 1 ) * c1 ), mul( create( n * ( n - 1 ) / 2 ), c0 ) );
	//ll ans = ( n - 1 ) * c1 + n * ( n - 1 ) / 2 * c0;
	priority_queue< pair< ll, pair< ll, ll > > > q;
	add( 0, 1, q );
	m[mp( 0, 1 )] = 1;
	n --;
	while( n > 0 ) {
		vector< ll > res = ans;
		ll s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		m[mp( p.X + 1, p.Y )] += m[p];
		m[mp( p.X, p.Y + 1 )] += m[p];
		if( p.Y == 1 )
			m[mp( p.X + 1, p.Y )] ++;
		add( p.X + 1, p.Y, q );
		add( p.X, p.Y + 1, q );

		ll k = m[p];
		ll r = n;
		ll l = n - k + 1;
		if( l < 0 ) {
			k += l;
			l = 0;
		}
		while( l <= r && c0 + s > l * c0 ) {
			l ++;
			k --;
		}
		if( l > r )
			break;
		res = sum( res, create( k * ( c0 + s ) ) );
		//res += k * ( c0 + c1 + s );
		res = sub( res, mul( create( ( l + r ) * ( r - l + 1 ) / 2 ), c0 ) );
		//res -= ( l + r ) * ( r - l + 1 ) / 2 * c0;
		n = l - 1;
		ans = res;
		//write( ans );
	}
	write( ans );
	//cout << ans << endl;
	return 0;
}

 #include <bits/stdc++.h>

using namespace std;

#define ll				long long
#define dd				double
#define X				first
#define Y				second
#define mp				make_pair
#define pb				push_back
#define forn( i, n )	for( ll i = 0; i < (ll) (n); i ++ )
#define endl			'\n'

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;

void add( ll x, ll y, priority_queue< pair< ll, pair< ll, ll > > > &q ) {
	if( u.find( mp( x, y ) ) != u.end() )
		return;
	u.insert( mp( x, y ) );
	q.push( mp( -( x * c0 + y * c1 ), mp( x, y ) ) );
}

ll mod = 1e1;

vector< ll > create( ll x ) {
	vector< ll > res;
	if( x == 0 ) {
		res.pb( 0 );
		return res;
	}
	while( x ) {
		res.pb( x % mod );
		x /= mod;
	}
	return res;
}

vector< ll > mul( vector< ll > v, ll x ) {
	vector< ll > res;
	ll ost = 0;
	forn( i, v.size() ) {
		res.pb( v[i] * x );
		res[i] += ost;
		ost = res[i] / mod;
		res[i] %= mod;
	}
	while( ost ) {
		res.pb( ost % mod );
ost /= mod;
}
	return res;
}

vector< ll > sum( vector< ll > a, vector< ll > b ) {
	vector< ll > res;
	ll n = max( a.size(), b.size() );
	ll ost = 0;
	forn( i, n ) {
		res.pb( ost );
		if( i < a.size() )
			res[i] += a[i];
		if( i < b.size() )
			res[i] += b[i];
		ost = res[i] / mod;
		res[i] %= mod;
	}

	while( ost ) {
		res.pb( ost % mod );
ost /= mod;
}
return res;
}

vector< ll > sub( vector< ll > a, vector< ll > b ) {
	vector< ll > res = a;
	forn( i, b.size() ) {
		res[i] -= b[i];
		if( res[i] < 0 ) {
			res[i] += mod;
			if( i + 1 < res.size() )
				res[i + 1] --;
			else
				return mul( create( 1e18 ), 1e8 );
		}
	}
if( b.size() < res.size() && res[b.size()] < 0 ) {
res[b.size()] += mod;
if( b.size() + 1 < res.size() )
res[b.size() + 1] --;
else
return mul( create( 1e18 ), 1e8 );
}
	return res;
}

bool check( vector< ll > a, vector< ll > b ) {
	while( a.size() < b.size() )
		a.pb( 0 );
	while( a.size() > b.size() )
		b.pb( 0 );
	for( ll i = a.size() - 1; i >= 0; i -- ) {
		if( a[i] == b[i] )
			continue;
		if( a[i] > b[i] )
			return true;
		else
			return false;
	}
}

void write( vector< ll > ans ) {
	bool ok = false;
	forn( ii, ans.size() ) {
		ll i = ans.size() - 1 - ii;
		if( !ok && ans[i] == 0 )
			continue;
if( ok ) {
ll m = mod / 10;
while( m ) {
ll x = ans[i] / m;
cout << x;
ans[i] -= x * m;
m /= 10;
}
} else
cout << ans[i];

		ok = true;
	}
	if( !ok )
		cout << 0;
	cout << endl;
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 > c1 )
		swap( c0, c1 );
	//vector< ll > ans = mul( create( n * ( n - 1 ) / 2 ), c0 );
	vector< ll > ans = sum( create( ( n - 1 ) * c1 ), mul( create( n * ( n - 1 ) / 2 ), c0 ) );
	//ll ans = ( n - 1 ) * c1 + n * ( n - 1 ) / 2 * c0;
	priority_queue< pair< ll, pair< ll, ll > > > q;
	add( 0, 1, q );
	m[mp( 0, 1 )] = 1;
	n --;
	while( n > 0 ) {
		vector< ll > res = ans;
		ll s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		m[mp( p.X + 1, p.Y )] += m[p];
		m[mp( p.X, p.Y + 1 )] += m[p];
		if( p.Y == 1 )
			m[mp( p.X + 1, p.Y )] ++;
		add( p.X + 1, p.Y, q );
		add( p.X, p.Y + 1, q );

		ll k = m[p];
		ll r = n;
		ll l = n - k + 1;
		if( l < 0 ) {
			k += l;
			l = 0;
		}
//l = ( c0 + s ) / c0;
while( l <= r && c0 + s > l * c0 ) {
l ++;
k --;
}
if( l > r )
break;
		res = sum( res, create( k * ( c0 + s ) ) );
		//res += k * ( c0 + c1 + s );
		//res -= k * c1;
		res = sub( res, mul( create( ( l + r ) * ( r - l + 1 ) / 2 ), c0 ) );
		//res -= ( l + r ) * ( r - l + 1 ) / 2 * c0;
		n = l - 1;
if( check( res, ans ) )
break;
		ans = res;
		//write( ans );
	}
	write( ans );
	//cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#ifdef ONLINE_JUDGE
#define OJ 1
#else
#define OJ 0
#endif

#define dd				double
#define ll 				long long
#define pb 				push_back
#define mp 				make_pair
#define X				first
#define Y				second
#define forn( i, n ) 	for( ll i = 0; i < (ll) (n); i ++ )
#define endl 			'\n'

#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

struct __s { __s() {
		srand( time( NULL ) );
		//freopen( "input.txt", "r", stdin ); freopen( "output.txt", "w", stdout );
		if( OJ ) { ios_base::Init i; cin.sync_with_stdio( 0 ); cin.tie( 0 ); }
	} ~__s() {
		if( !OJ ) TIMESTAMP;
		ll n; cin >> n;
	}
} __S;

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;
priority_queue< pair< ll, pair< ll, ll > > > q;

void add( ll x, ll y, ll s ) {
	pair< ll, ll > p = mp( x, y );
	m[p] += s;
	if( u.find( p ) != u.end() )
		return;
	u.insert( p );
	q.push( mp( -( x * c0 + y * c1 ), p ) );
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 == 0 || c1 == 0 ) {
		ll ans = ( n - 1 ) * max( c1, c0 );
		cout << ans << endl;
		return 0;
	}
	n -= 2;
	add( 0, 1, 1 );
	add( 1, 0, 1 );
	ll ans = c0 + c1;
	while( n ) {
		ll s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		add( p.X + 1, p.Y, m[p] );
		add( p.X, p.Y + 1, m[p] );
		ll k = min( n, m[p] );
		n -= k;
		ans += 1LL * k * ( s + c0 + c1 );
	}
	cout << ans << endl;
	return 0;
}

 #include <bits/stdc++.h>

using namespace std;

#define ll				long long
#define dd				double
#define X				first
#define Y				second
#define mp				make_pair
#define pb				push_back
#define forn( i, n )	for( ll i = 0; i < (ll) (n); i ++ )
#define endl			'\n'

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;

void add( ll x, ll y, priority_queue< pair< ll, pair< ll, ll > > > &q ) {
	if( u.find( mp( x, y ) ) != u.end() )
		return;
	u.insert( mp( x, y ) );
	q.push( mp( -( x * c0 + y * c1 ), mp( x, y ) ) );
}

ll mod = 1e10;

vector< ll > create( ll x ) {
	vector< ll > res;
	if( x == 0 ) {
		res.pb( 0 );
		return res;
	}
	while( x ) {
		res.pb( x % mod );
		x /= mod;
	}
	return res;
}

vector< ll > mul( vector< ll > v, ll x ) {
	vector< ll > res;
	ll ost = 0;
	forn( i, v.size() ) {
		res.pb( v[i] * x );
		res[i] += ost;
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sum( vector< ll > a, vector< ll > b ) {
	vector< ll > res;
	ll n = max( a.size(), b.size() );
	ll ost = 0;
	forn( i, n ) {
		res.pb( ost );
		if( i < a.size() )
			res[i] += a[i];
		if( i < b.size() )
			res[i] += b[i];
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sub( vector< ll > a, vector< ll > b ) {
	vector< ll > res = a;
	forn( i, b.size() ) {
		res[i] -= b[i];
		if( res[i] < 0 ) {
			res[i] += mod;
			if( i + 1 < res.size() )
				res[i + 1] --;
			else
				return mul( create( 1e18 ), 1e8 );
		}
	}
	return res;
}

bool check( vector< ll > a, vector< ll > b ) {
	while( a.size() < b.size() )
		a.pb( 0 );
	while( a.size() > b.size() )
		b.pb( 0 );
	for( ll i = a.size() - 1; i >= 0; i -- ) {
		if( a[i] == b[i] )
			continue;
		if( a[i] > b[i] )
			return true;
		else
			return false;
	}
}

void write( vector< ll > ans ) {
	bool ok = false;
	forn( ii, ans.size() ) {
		ll i = ans.size() - 1 - ii;
		if( !ok && ans[i] == 0 )
			continue;
if( ok ) {
ll m = mod / 10;
while( m ) {
ll x = ans[i] / m;
cout << x;
ans[i] -= x * m;
m /= 10;
}
} else
cout << ans[i];

		ok = true;
	}
	if( !ok )
		cout << 0;
	cout << endl;
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 > c1 )
		swap( c0, c1 );
	//vector< ll > ans = mul( create( n * ( n - 1 ) / 2 ), c0 );
	vector< ll > ans = sum( create( ( n - 1 ) * c1 ), mul( create( n * ( n - 1 ) / 2 ), c0 ) );
	//ll ans = ( n - 1 ) * c1 + n * ( n - 1 ) / 2 * c0;
	priority_queue< pair< ll, pair< ll, ll > > > q;
	add( 0, 1, q );
	m[mp( 0, 1 )] = 1;
	n --;
	while( n > 0 ) {
		vector< ll > res = ans;
		ll s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		m[mp( p.X + 1, p.Y )] += m[p];
		m[mp( p.X, p.Y + 1 )] += m[p];
		if( p.Y == 1 )
			m[mp( p.X + 1, p.Y )] ++;
		add( p.X + 1, p.Y, q );
		add( p.X, p.Y + 1, q );

		ll k = m[p];
		ll r = n;
		ll l = n - k + 1;
		if( l < 0 ) {
			k += l;
			l = 0;
		}
//l = ( c0 + s ) / c0;
while( l <= r && c0 + s > l * c0 ) {
l ++;
k --;
}
if( l > r )
break;
		res = sum( res, create( k * ( c0 + s ) ) );
		//res += k * ( c0 + c1 + s );
		//res -= k * c1;
		res = sub( res, mul( create( ( l + r ) * ( r - l + 1 ) / 2 ), c0 ) );
		//res -= ( l + r ) * ( r - l + 1 ) / 2 * c0;
		n = l - 1;
if( check( res, ans ) )
break;
		ans = res;
		//write( ans );
	}
	write( ans );
	//cout << ans << endl;
	return 0;
}

 #include <bits/stdc++.h>

using namespace std;

#define ll				long long
#define dd				double
#define X				first
#define Y				second
#define mp				make_pair
#define pb				push_back
#define forn( i, n )	for( ll i = 0; i < (ll) (n); i ++ )
#define endl			'\n'

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;

void add( ll x, ll y, priority_queue< pair< ll, pair< ll, ll > > > &q ) {
	if( u.find( mp( x, y ) ) != u.end() )
		return;
	u.insert( mp( x, y ) );
	q.push( mp( -( x * c0 + y * c1 ), mp( x, y ) ) );
}

ll mod = 1e2;

vector< ll > create( ll x ) {
	vector< ll > res;
	if( x == 0 ) {
		res.pb( 0 );
		return res;
	}
	while( x ) {
		res.pb( x % mod );
		x /= mod;
	}
	return res;
}

vector< ll > mul( vector< ll > v, ll x ) {
	vector< ll > res;
	ll ost = 0;
	forn( i, v.size() ) {
		res.pb( v[i] * x );
		res[i] += ost;
		ost = res[i] / mod;
		res[i] %= mod;
	}
	while( ost ) {
		res.pb( ost % mod );
ost /= mod;
}
	return res;
}

vector< ll > sum( vector< ll > a, vector< ll > b ) {
	vector< ll > res;
	ll n = max( a.size(), b.size() );
	ll ost = 0;
	forn( i, n ) {
		res.pb( ost );
		if( i < a.size() )
			res[i] += a[i];
		if( i < b.size() )
			res[i] += b[i];
		ost = res[i] / mod;
		res[i] %= mod;
	}

	while( ost ) {
		res.pb( ost % mod );
ost /= mod;
}
return res;
}

vector< ll > sub( vector< ll > a, vector< ll > b ) {
	vector< ll > res = a;
	forn( i, b.size() ) {
		res[i] -= b[i];
		if( res[i] < 0 ) {
			res[i] += mod;
			if( i + 1 < res.size() )
				res[i + 1] --;
			else
				return mul( create( 1e18 ), 1e8 );
		}
	}
if( b.size() < res.size() && res[b.size()] < 0 ) {
res[b.size()] += mod;
if( b.size() + 1 < res.size() )
res[b.size() + 1] --;
else
return mul( create( 1e18 ), 1e8 );
}
	return res;
}

bool check( vector< ll > a, vector< ll > b ) {
	while( a.size() < b.size() )
		a.pb( 0 );
	while( a.size() > b.size() )
		b.pb( 0 );
	for( ll i = a.size() - 1; i >= 0; i -- ) {
		if( a[i] == b[i] )
			continue;
		if( a[i] > b[i] )
			return true;
		else
			return false;
	}
}

void write( vector< ll > ans ) {
	bool ok = false;
	forn( ii, ans.size() ) {
		ll i = ans.size() - 1 - ii;
		if( !ok && ans[i] == 0 )
			continue;
if( ok ) {
ll m = mod / 10;
while( m ) {
ll x = ans[i] / m;
cout << x;
ans[i] -= x * m;
m /= 10;
}
} else
cout << ans[i];

		ok = true;
	}
	if( !ok )
		cout << 0;
	cout << endl;
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 > c1 )
		swap( c0, c1 );
	//vector< ll > ans = mul( create( n * ( n - 1 ) / 2 ), c0 );
	vector< ll > ans = sum( create( ( n - 1 ) * c1 ), mul( create( n * ( n - 1 ) / 2 ), c0 ) );
	//ll ans = ( n - 1 ) * c1 + n * ( n - 1 ) / 2 * c0;
	priority_queue< pair< ll, pair< ll, ll > > > q;
	add( 0, 1, q );
	m[mp( 0, 1 )] = 1;
	n --;
	while( n > 0 ) {
		vector< ll > res = ans;
		ll s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		m[mp( p.X + 1, p.Y )] += m[p];
		m[mp( p.X, p.Y + 1 )] += m[p];
		if( p.Y == 1 )
			m[mp( p.X + 1, p.Y )] ++;
		add( p.X + 1, p.Y, q );
		add( p.X, p.Y + 1, q );

		ll k = m[p];
		ll r = n;
		ll l = n - k + 1;
		if( l < 0 ) {
			k += l;
			l = 0;
		}
//l = ( c0 + s ) / c0;
while( l <= r && c0 + s > l * c0 ) {
l ++;
k --;
}
if( l > r )
break;
		res = sum( res, create( k * ( c0 + s ) ) );
		//res += k * ( c0 + c1 + s );
		//res -= k * c1;
		res = sub( res, mul( create( ( l + r ) * ( r - l + 1 ) / 2 ), c0 ) );
		//res -= ( l + r ) * ( r - l + 1 ) / 2 * c0;
		n = l - 1;
if( check( res, ans ) )
break;
		ans = res;
		//write( ans );
	}
	write( ans );
	//cout << ans << endl;
	return 0;
}

 #include <bits/stdc++.h>

using namespace std;

#define ll				long long
#define dd				double
#define X				first
#define Y				second
#define mp				make_pair
#define pb				push_back
#define forn( i, n )	for( ll i = 0; i < (ll) (n); i ++ )
#define endl			'\n'

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;

void add( ll x, ll y, priority_queue< pair< ll, pair< ll, ll > > > &q ) {
	if( u.find( mp( x, y ) ) != u.end() )
		return;
	u.insert( mp( x, y ) );
	q.push( mp( -( x * c0 + y * c1 ), mp( x, y ) ) );
}

ll mod = 1e2;

vector< ll > create( ll x ) {
	vector< ll > res;
	if( x == 0 ) {
		res.pb( 0 );
		return res;
	}
	while( x ) {
		res.pb( x % mod );
		x /= mod;
	}
	return res;
}

vector< ll > mul( vector< ll > v, ll x ) {
	vector< ll > res;
	ll ost = 0;
	forn( i, v.size() ) {
		res.pb( v[i] * x );
		res[i] += ost;
		ost = res[i] / mod;
		res[i] %= mod;
	}
	while( ost ) {
		res.pb( ost % mod );
ost /= mod;
}
	return res;
}

vector< ll > sum( vector< ll > a, vector< ll > b ) {
	vector< ll > res;
	ll n = max( a.size(), b.size() );
	ll ost = 0;
	forn( i, n ) {
		res.pb( ost );
		if( i < a.size() )
			res[i] += a[i];
		if( i < b.size() )
			res[i] += b[i];
		ost = res[i] / mod;
		res[i] %= mod;
	}

	while( ost ) {
		res.pb( ost % mod );
ost /= mod;
}
return res;
}

vector< ll > sub( vector< ll > a, vector< ll > b ) {
	vector< ll > res = a;
	forn( i, b.size() ) {
		res[i] -= b[i];
		if( res[i] < 0 ) {
			res[i] += mod;
			if( i + 1 < res.size() )
				res[i + 1] --;
			else
				return mul( create( 1e18 ), 1e8 );
		}
	}
	return res;
}

bool check( vector< ll > a, vector< ll > b ) {
	while( a.size() < b.size() )
		a.pb( 0 );
	while( a.size() > b.size() )
		b.pb( 0 );
	for( ll i = a.size() - 1; i >= 0; i -- ) {
		if( a[i] == b[i] )
			continue;
		if( a[i] > b[i] )
			return true;
		else
			return false;
	}
}

void write( vector< ll > ans ) {
	bool ok = false;
	forn( ii, ans.size() ) {
		ll i = ans.size() - 1 - ii;
		if( !ok && ans[i] == 0 )
			continue;
if( ok ) {
ll m = mod / 10;
while( m ) {
ll x = ans[i] / m;
cout << x;
ans[i] -= x * m;
m /= 10;
}
} else
cout << ans[i];

		ok = true;
	}
	if( !ok )
		cout << 0;
	cout << endl;
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 > c1 )
		swap( c0, c1 );
	//vector< ll > ans = mul( create( n * ( n - 1 ) / 2 ), c0 );
	vector< ll > ans = sum( create( ( n - 1 ) * c1 ), mul( create( n * ( n - 1 ) / 2 ), c0 ) );
	//ll ans = ( n - 1 ) * c1 + n * ( n - 1 ) / 2 * c0;
	priority_queue< pair< ll, pair< ll, ll > > > q;
	add( 0, 1, q );
	m[mp( 0, 1 )] = 1;
	n --;
	while( n > 0 ) {
		vector< ll > res = ans;
		ll s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		m[mp( p.X + 1, p.Y )] += m[p];
		m[mp( p.X, p.Y + 1 )] += m[p];
		if( p.Y == 1 )
			m[mp( p.X + 1, p.Y )] ++;
		add( p.X + 1, p.Y, q );
		add( p.X, p.Y + 1, q );

		ll k = m[p];
		ll r = n;
		ll l = n - k + 1;
		if( l < 0 ) {
			k += l;
			l = 0;
		}
//l = ( c0 + s ) / c0;
while( l <= r && c0 + s > l * c0 ) {
l ++;
k --;
}
if( l > r )
break;
		res = sum( res, create( k * ( c0 + s ) ) );
		//res += k * ( c0 + c1 + s );
		//res -= k * c1;
		res = sub( res, mul( create( ( l + r ) * ( r - l + 1 ) / 2 ), c0 ) );
		//res -= ( l + r ) * ( r - l + 1 ) / 2 * c0;
		n = l - 1;
if( check( res, ans ) )
break;
		ans = res;
		//write( ans );
	}
	write( ans );
	//cout << ans << endl;
	return 0;
}

/*
Author: CNYALI_LK
LANG: C++
PROG: B.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %lld\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %lld\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const signed inf=0x3f3f3f3f;
const double eps=1e-8;
const double pi=acos(-1.0);
template<class T>ll chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>ll chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
template<class T>ll dcmp(T a,T b){return a>b;}
template<ll *a>ll cmp_a(ll x,ll y){return a[x]<a[y];}
#define min mmin
#define max mmax
#define abs aabs
namespace io {
	const ll SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; ll f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// prll the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed lleger
	inline void read (signed &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}

	inline void read (long long &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	inline void read (char &x) {
		x=gc();
	}
	inline void read(char *x){
		while((*x=gc())=='\n' || *x==' '||*x=='\r');
		while(!(*x=='\n'||*x==' '||*x=='\r'))*(++x)=gc();
	}
	template<typename A,typename ...B>
	inline void read(A &x,B &...y){
		read(x);read(y...);
	}
	// prll a signed lleger
	inline void write (signed x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}

	inline void write (long long x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	inline void write (char x) {
		putc(x);
	}
	inline void write(const char *x){
		while(*x){putc(*x);++x;}
	}
	inline void write(char *x){
		while(*x){putc(*x);++x;}
	}
	template<typename A,typename ...B>
	inline void write(A x,B ...y){
		write(x);write(y...);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: write;
ll c0,c1,n;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lls[31];
ll C(ll a,ll b){
	ll s=1,x,g;
	for(ll i=1;i<=b;++i)lls[i]=i;
	for(ll i=0;i<b;++i){
		x=a+b-i;
		for(ll j=1;j<=b;++j){
			g=gcd(lls[j],x);
			x/=g;
			lls[j]/=g;
		}
		if(x>inf/s)return inf;
		s*=x;
	}
	return s;
}
#define chk if(tmp>n)return 1
ll check(ll x){
	ll tmp=x/c0+x/c1+1;
	chk;
	for(ll i=1;i<=26;++i){
		for(ll j=i;j*c0+i*c1<=x;++j){
			tmp+=C(j,i);
			chk;
		}
		for(ll j=i+1;j*c1+i*c0<=x;++j){
			tmp+=C(j,i);
			chk;
		}
	}
	return 0;
}
void Work(ll x,ll &tmp,ll &ans){
	tmp=x/c0+x/c1+1;
	ans=((x/c0)*(x/c0+1)*c0+(x/c1)*(x/c1+1)*c1)>>1;
	ll c;
	for(ll i=1;i<=26;++i){
		for(ll j=i;j*c0+i*c1<=x;++j){
			c=C(j,i);
			tmp+=c;
			ans+=c*(j*c0+i*c1);
		}
		for(ll j=i+1;j*c1+i*c0<=x;++j){
			c=C(j,i);
			tmp+=c;
			ans+=c*(j*c1+i*c0);
		}
	}
}

int main(){
#ifdef cnyali_lk
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
#endif
	read(n,c0,c1);
	--n;
	if(c0>c1)swap(c0,c1);
	if(!c0)printf("%lld\n",n*c1);
	else{
		ll l=0,r=c1*26,mid;
		while(l<=r){
			mid=(l+r)>>1;
			if(check(mid))r=mid-1;
			else l=mid+1;
		}
		ll c,s;
		Work(l-1,c,s);
		s+=(n-c)*l+n*(c0+c1);
		printf("%lld\n",s);
	}
	return 0;
}

#include<cstdio>
#include<cmath>
#define ll long long
const int S=2e4;
int n,m,s,a,b,c[S];ll l,r,ans;
bool check(ll m){
	int sum=m/a,i,j;
	for (i=0;i<=s;i++) c[i]=i+1;
	for (i=1;(ll)i*b<=m&&sum<n;i++)
		for (j=0;(ll)i*b+(ll)j*a<=m&&sum<n;j++){
			sum+=c[j];if (j) c[j]+=c[j-1];
		}
	return sum>=n;
}
void slove(ll m){
	int sum=m/a,i,j;
	ans+=(ll)sum*(sum+1)/2*a;
	for (i=0;i<=s;i++) c[i]=i+1;
	for (i=1;(ll)i*b<=m;i++)
		for (j=0;(ll)i*b+(ll)j*a<=m;j++){
			sum+=c[j];ans+=c[j]*((ll)i*b+(ll)j*a);
			if (j) c[j]+=c[j-1];
		}
	ans-=m*(sum-n);
}
int main(){
	scanf("%d%d%d",&n,&a,&b);
	if (a>b) a^=b,b^=a,a^=b;
	n--;ans+=(ll)n*(a+b);
	n--;s=sqrt(n*2)+1;
	if (!a){printf("%I64d",ans);return 0;}
	for (r=(ll)n*a;l<r;){ll m=l+r>>1;
		if (check(m)) r=m; else l=m+1;
	}
	slove(l);
	printf("%I64d",ans);
}

#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
using namespace std;

int n, c1, c2, tot = 1, stk[20]; ll ans; map<ll, int> m;
priority_queue<ll, vector<ll>, greater<ll> > hp;

int main() {
    scanf("%d%d%d", &n, &c1, &c2);
    if (!c1 && !c2) {puts("0"); return 0;}
    if (!c1 || !c2) {printf("%lld\n", (1LL * (n - 1) * max(c1, c2))); return 0;}
    hp.push(0); m[0] = 1;
    while (tot < n) {
        ll x = hp.top(); hp.pop();
        int u = min(m[x], n - tot);
        m[x] -= u; tot += u;
        ans += 1LL * u * (c1 + c2) + x * u;
        if (!m[x + c1]) m[x + c1] = u, hp.push(x + c1);
        else m[x + c1] += u;
        if (!m[x + c2]) m[x + c2] = u, hp.push(x + c2);
        else m[x + c2] += u;
    }
    printf("%lld\n", ans);
    return 0;
}

#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,c0,c1,C[70][50010];
const int N=60,M=40000;
struct atom{
	long long w;
	int num;
}A[50];
int len;
int check(long long lim){
	int now=min(1ll*n,lim/c1);
	for (int i=1;i<=N;i++){
		int j=0;
		while (1ll*i*c0+1ll*j*c1<=lim&&now<n){
			now=min(n,now+C[i][j]); j++;
		}
	}
	return now;
}
int compare(atom k1,atom k2){
	return k1.w<k2.w;
}
long long calc(long long lim){
//	cout<<"asd "<<lim<<endl;
	long long ans=1ll*n*(c0+c1); int len=0;
	int k=lim/c1; A[++len]=(atom){1ll*k*c1,1};
	int rem=n;
	k--; if (k>=0) ans+=1ll*(k+1)*k/2*c1,rem-=k+1;
	for (int i=1;i<=N;i++){
		int j=0;
		while (1ll*i*c0+1ll*j*c1<=lim) j++;
		j--; if (j<0) continue;
		A[++len]=(atom){1ll*i*c0+1ll*j*c1,C[i][j]}; j--;
		while (j>=0){
			ans+=(1ll*i*c0+1ll*j*c1)*C[i][j]; rem-=C[i][j]; j--;
		}
	}
//	cout<<rem<<endl;
	sort(A+1,A+len+1,compare);
	for (int i=1;i<=len;i++){
		int k=min(rem,A[i].num);
		ans+=1ll*k*A[i].w; rem-=k;
	}
	return ans;
}
int main(){
	scanf("%d%d%d",&n,&c0,&c1);
	if (c0<c1) swap(c0,c1); n--;
	if (n==0){
		cout<<0<<endl; return 0;
	}
	if (c1==0){
		cout<<1ll*n*c0<<endl; return 0;
	}
	for (int i=0;i<=M;i++) C[0][i]=1;
	for (int i=1;i<=N;i++){
		C[i][0]=1;
		for (int j=1;j<=M;j++) C[i][j]=min(C[i-1][j]+C[i][j-1],n);
	}
	long long l=0,r=1e17,ans=0;
	while (l<r){
		long long mid=l+r>>1;
		if (check(mid)>=n){
			ans=mid; r=mid;
		} else l=mid+1;
	}
//	cout<<ans<<endl;
	cout<<calc(ans)<<endl;
	return 0;
}

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#define clr(x) memset((x), 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define sz size()
#define For(i, st, en) for(int i=(st); i<=(int)(en); i++)
#define Ford(i, st, en) for(int i=(st); i>=(int)(en); i--)
#define forn(i, n) for(int i=0; i<(int)(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

#ifdef ROOM_311
__attribute__((destructor)) void fini_main()
{
	fprintf(stderr, "Execution time = %0.0lf ms\n", clock() * 1000.0 / CLOCKS_PER_SEC);
}
#endif

#define MY_RAND 1
#if MY_RAND
uint64_t rnd_data = 0xDEADBEEFDULL;
inline void my_srand(int seed) { rnd_data = ((uint64_t)seed << 16) | 0x330E; }
inline int my_rand() { rnd_data = rnd_data * 0x5DEECE66DULL + 0xB; return (rnd_data >> 17) & 0x7FFFFFFF; }
#define rand my_rand
#define srand my_srand
#endif

template <class _T> inline _T sqr(const _T &x) { return x * x; }
template <class _T> inline string tostr(const _T &a) { ostringstream os(""); os << a; return os.str(); }

// Types
typedef long double ld;
typedef long long i64;
typedef unsigned long long u64;
typedef pair < int, int > PII;
typedef set < int > SI;
typedef vector < int > VI;
typedef map < string, int > MSI;

// Constants
const ld PI = 3.1415926535897932384626433832795L;
const ld EPS = 1e-11;

const int MAXQ = 10240000;

int n, c0, c1;
int q[MAXQ];

void solve2()
{
	int cc = c0 + c1;
	i64 ans = 0;
	clr(q);
	int k = 0;
	for (n--; n; k++)
	{
		while (k < c1 && k % c0) ++k;
		int add;
		if (k < c1)
		{
			add = 1;
		}
		else
		{
			while (!q[k - c1]) ++k;
			add = min(n, q[k - c1]);
		}
		ans += (k + cc) * (i64)add;
		int k1 = k + c0;
		int k2 = k + c1;
		if (k1 >= c1 && k1 - c1 < MAXQ) q[k1 - c1] += add;
		if (k2 >= c1 && k2 - c1 < MAXQ) q[k2 - c1] += add;
		n -= add;
	}
	printf("%lld\n", ans);
}

int main()
{
#ifdef ROOM_311
	freopen("input.txt", "rt", stdin);
#endif
	cout << setiosflags(ios::fixed) << setprecision(10);

	scanf("%d%d%d", &n, &c0, &c1);
	if (c0 > c1) swap(c0, c1);
	if (!c0)
	{
		printf("%lld\n", c1 * (i64)(n - 1));
		return 0;
	}
	if (c1 / c0 > 1000000)
	{
		solve2();
		return 0;
	}
	map < i64, i64 > q;
	int cc = c0 + c1;
	n--;
	q[0] = 1;
	i64 ans = 0;
	i64 last = 0;
	while (n)
	{
		__typeof(q.begin()) it = q.begin();
		i64 k = it->first;
		int add = min((i64)n, it->second);
		q.erase(it);
		last = k;
		ans += (k + cc) * (i64)add;
		i64 k1 = k + c0;
		i64 k2 = k + c1;
		q[k1] += add;
		q[k2] += add;
		n -= add;
	}
	fprintf(stderr, "last = %lld\n", last);
	printf("%lld\n", ans);

	return 0;
}

#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
int n;ll x,y;
bool check(ll mid,ll&sum){
	ll ret=mid/x+mid/y+1;
	sum+=(x+mid/x*x)*(mid/x)/2+(y+mid/y*y)*(mid/y)/2;
	if(ret>=n)return 1;
	for(int i=1;i<=26;++i){
		ll C=1;
		for(int j=1;j*x+i*y<=mid;++j){C=C*(i+j)/j;sum+=C*(j*x+i*y);if((ret+=C)>=n)return 1;}
	}
	sum+=(n-ret)*(mid+1);
	return 0;
}
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	n=gi()-1,x=gi(),y=gi();
	if(x>y)std::swap(x,y);
	if(!x)printf("%lld\n",1ll*y*n),exit(0);
	ll l=0,r=26*y,mid,ans=0;
	while(l<r){
		mid=l+r>>1;
		if(check(mid,ans))r=mid;else l=mid+1;
	}
	ans=0;check(l-1,ans);
	printf("%lld\n",ans+(x+y)*n);
	return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
ll ans;
int n,a,b,S;
int c[20005];
bool check(ll m){
	int sum=m/a;
	For(i,0,S) c[i]=i+1;
	for (int i=1;1ll*i*b<=m&&sum<n;++i)
		for (int j=0;1ll*i*b+1ll*j*a<=m&&sum<n;j++)
			sum+=c[j],c[j]+=(j?c[j-1]:0);
	return sum>=n;
}
void calc(ll m){
	int sum=m/a;
	ans+=1ll*sum*(sum+1)/2*a;
	For(i,0,S) c[i]=i+1;
	for (int i=1;1ll*i*b<=m;++i)
		for (int j=0;1ll*i*b+1ll*j*a<=m;j++){
			ans+=1ll*c[j]*(1ll*i*b+1ll*j*a);
			sum+=c[j],c[j]+=(j?c[j-1]:0);
		}
	//cout<<ans<<' '<<sum<<' '<<m<<endl;
	ans-=m*(sum-n);
}
int main(){
	scanf("%d%d%d",&n,&a,&b);
	if (a>b) swap(a,b);
	n--; ans=1ll*n*(a+b);
	n--; S=sqrt(n*2)+1;
	if (!a) return printf("%lld\n",ans),0;
	ll l=0,r=1ll*n*a,p;
	while (l<=r){
		ll mid=(l+r)/2;
		if (check(mid)) p=mid,r=mid-1;
		else l=mid+1;
	}
	calc(p);
	printf("%lld\n",ans);
} //hello

#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...)
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)

#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 1000010

template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}

//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

int main(){
    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);
    int i,j,k=0,ca=0,T,K,n,m=0;
    int c0,c1;
    scanf("%d%d%d",&n,&c0,&c1);
    if(c0>c1)swap(c0,c1);
    if(c0==0){
        cout<<1LL*(n-1)*c1<<"\n";return 0;
    }
    map<ll,int>g;
    ll cc=c0+c1,ans=0;
    g[0]=1;n--;
    while(n){
        ll a=g.begin()->x;int b=g.begin()->y;g.erase(g.begin());
        int c=min(n,b);
        ans+=(a+cc)*c;
        g[a+c0]+=b;
        g[a+c1]+=b;
        n-=c;
    }
    printf("%I64d\n",ans);
    //cerr<<1.*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}

#include<cstdio>
#include<algorithm>
using namespace std;
int n,x,y;
long long s[31];
long long gcd(long long x,long long y)
{
	if (!y) return x;
	return gcd(y,x%y);
}
long long C(long long x,long long y)
{
	long long num=1;
	for (int i=1;i<=y;i++) s[i]=i;
	for (int i=0;i<y;i++)
	{
		long long t=x-i;
		for (int i=1;i<=y;i++)
		{
			long long dt=gcd(s[i],t);
			s[i]/=dt,t/=dt;
		}
		num=num*t;
	}
	return num;
}
long long calc(long long k)
{
	long long sum=(k/x)+(k/y)+1;
	if (sum>n) return 0;
	for (long long i=1;y*i<=k;i++)
	{
		long long num=k-y*i;
		for (long long j=1;j*x<=num;j++)
		{
			sum+=C(j+i,i);
			if (sum>n) return 0;
		}
	 }
	 return 1;
}
long long solve(long long k)
{
 	long long sum=(k/x)+(k/y)+1;
 	long long ans=(k/x)*(k/x+1)/2*x+(k/y)*(k/y+1)/2*y;
	if (sum>n) return 0;
	for (long long i=1;y*i<=k;i++)
	{
		long long num=k-y*i;
		for (long long j=1;j*x<=num;j++)
		{
			long long dt=C(j+i,i);
			sum+=dt;
			ans+=dt*(j*x+y*i);
		}
	 }
	ans+=(k+1)*(n-sum);
	ans+=1ll*n*(x+y);
	return ans;
}
int main()
{
	scanf("%d%d%d",&n,&x,&y);
	n--;
	if (x>y) swap(x,y);
	if (!x)
	{
		printf("%lld\n",1ll*n*y);
		return 0;
	}
	long long l=0,r=1ll*y*26;
	while (l<r)
	{
		long long mid=(l+r+1)>>1;
		if (calc(mid)) l=mid;
		 else r=mid-1;
	}
//	printf("%lld\n",l);
	printf("%lld\n",solve(l));
}

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }

long long nCr_saturated(long long n, long long k) {
	if(k > n) return 0;
	if(k > n / 2) k = n - k;
	if(k == 0) return 1;
	long long r = 1;
	for(int j = 1; j <= k; j ++) {
		ll a = n - k + j; int b = j;
		{
			int g = gcd((int)((n - k) % j), j);
			a /= g, b /= g;
		}
		r /= b;
		if(r * 1. * a > 2e18)
			return (long long)1e18 + 1;
		r *= a;
	}
	return min(r, (long long)1e18 + 1);
}

long long nCr(long long n, ll k) {
	return nCr_saturated(n, k);
}

long long calcCount(long long bound, ll c0, ll c1) {
	assert(c0 <= c1);
	long long r = 0;
	for(ll x = 0; (long long)x * c1 < bound; ++ x) {
		long long y = (bound - (long long)x * c1 - 1) / c0;
		//\sum_{i=0}^y C(x+i,x) = C(x+y+1,x+1)
		r += nCr(x + y + 1, x + 1);
		if(r > 1e18) return INFL;
	}
	return r;
}

long long calcSum(ll x, long long y, ll c0, ll c1) {
	return (y + 1) * nCr(x + y + 1, x) * (c0 * y + c1 * (x + 2LL)) / (x + 2);
}

int main() {
	int n; int c0; int c1;
	while(~scanf("%d%d%d", &n, &c0, &c1)) {
		if(c0 > c1) swap(c0, c1);
		if(c0 == 0) {
			long long ans = (long long)c1 * (n - 1);
			printf("%lld\n", ans);
			continue;
		}
		long long lo = 0, up = 1;
		while(calcCount(up, c0, c1) < n - 1) up *= 2;
		while(up - lo > 0) {
			long long mid = (lo + up + 1) / 2;
			if(calcCount(mid, c0, c1) > n - 1)
				up = mid - 1;
			else
				lo = mid;
		}
		long long bound = up;
		cerr << bound << ": " << calcCount(bound, c0, c1) << ", " << calcCount(bound + 1, c0, c1) << endl;
		long long ans = 0;
		for(ll x = 0; (long long)x * c1 < bound; ++ x) {
			long long y = (bound - (long long)x * c1 - 1) / c0;
			ans += (c1 * x + c0 * (y + 1)) * nCr(x + y, x);
			//i >= (bound - c1 * (x + 1)) / c0
			long long iL = (bound - c1 * (x + 1) + c0 - 1) / c0;
			if(y < iL) continue;
			ans += calcSum(x, y, c0, c1);
			if(0 < iL) ans -= calcSum(x, iL - 1, c0, c1);
		}
		ll rem = (n - 1) - calcCount(bound, c0, c1);
		assert(rem >= 0);
		ans += rem * (bound + c0 + c1);
		printf("%lld\n", ans);
	}
	return 0;
}

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <list>
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int CMAX=1000;

int n,c0,c1;
int C[CMAX+1][CMAX+1];

// a*c0+b*c1<=c, a>=0,b>=0 -> sum C[a+b][a] for all possible (a,b)
int calccnt(ll c) {
	if(c0==0) return n;
	int ret=0;
	for(int b=0;(ll)b*c1<=c;++b) {
		ll mxa=(c-(ll)c1*b)/c0;
		if(ret+mxa+1>=n) return n;
		if(b==0) { ret+=mxa+1; continue; }
		if(ret+(mxa+2)*(mxa+1)/2>=n) return n;
		if(b==1) { ret+=(mxa+2)*(mxa+1)/2; continue; }
		if(ret+(mxa+1)*(mxa+2)*(mxa+3)/6>=n) return n;
		if(b==2) { ret+=(mxa+1)*(mxa+2)*(mxa+3)/6; continue; }
		assert(mxa+b<=CMAX);
		REPE(a,mxa) if((ret+=C[a+b][a])>=n) return n;
	}
	return ret;
}
ll calcsum(ll c) {
	ll ret=0;
	for(int b=0;(ll)b*c1<=c;++b) {
		ll mxa=(c-(ll)c1*b)/c0;
		if(b==0) { ret+=0*c1*(mxa+1)+c0*mxa*(mxa+1)/2; continue; }
		if(b==1) { ret+=1*c1*(mxa+2)*(mxa+1)/2+2*c0*mxa*(mxa+1)*(mxa+2)/6; continue; }
		if(b==2) { ret+=2*c1*(mxa+1)*(mxa+2)*(mxa+3)/6+3*c0*(mxa+3)*(mxa+2)*(mxa+1)*(mxa)/24; continue; }
		assert(mxa+b<=CMAX);
		REPE(a,mxa) ret+=C[a+b][a]*((ll)a*c0+(ll)b*c1);
	}
	return ret;
}

void run() {
	scanf("%d%d%d",&n,&c0,&c1); if(c0>c1) swap(c0,c1);
	REPE(i,CMAX) { C[i][0]=C[i][i]=1; FOR(j,1,i) if((C[i][j]=C[i-1][j-1]+C[i-1][j])>=n) C[i][j]=n; }

	ll l=-1,h=(ll)(n-2)*min(c0,c1);
	while(l+1<h) {
		ll m=l+(h-l)/2;
		if(calccnt(m)>=n-1) h=m; else l=m;
	}
	ll splitmx=h;
	ll ret=(ll)(n-1)*(c0+c1);
	if(splitmx!=0) {
		ll cntmx=n-1-calccnt(splitmx-1);
		//printf("max splitcost = %lld (%lld times)\n",splitmx,cntmx);
		ret+=cntmx*splitmx;
		ret+=calcsum(splitmx-1);
	}
	printf("%lld\n",ret);
}

int main() {
	run();
	return 0;
}

#include <cstdio>
#include <algorithm>
#define cs const
#define inf 2147483647
using namespace std;
typedef long long ll;
typedef cs ll& cll;
typedef cs int& ci;
ll c0,c1,n;
ll gcd(cll a,cll b){
	return b?gcd(b,a%b):a;
}
ll lls[31];
ll comb(cll a,ci b){
    ll s=1,x,g;
    for(int i=0; ++i<=b; lls[i]=i);
    for(int i=-1; ++i<b; ){
    	x=a+b-i;
    	for(ll j=0; ++j<=b; ){
    		g=gcd(lls[j],x);
    		x/=g;
    		lls[j]/=g;
		}
		if(x>inf/s)
			return inf;
		s*=x;
	}
    return s;
}
bool check(cll x){
	ll tmp=x/c0+x/c1+1;
	if(tmp>n)
    	return 1;
    for(int i=0; ++i<=26; ){
		for(ll j=i-1; (++j)*c0+i*c1<=x; )
			if((tmp+=comb(j,i))>n)
				return 1;
		for(ll j=i; (++j)*c1+i*c0<=x; )
			if((tmp+=comb(j,i))>n)
				return 1;
	}
	return 0;
}
void work(cll x,ll&tmp,ll&ans){
	tmp=x/c0+x/c1+1;
	ans=((x/c0)*(x/c0+1)*c0+(x/c1)*(x/c1+1)*c1)>>1;
	ll c;
	for(int i=0; ++i<=26; ){
		for(ll j=i-1; (++j)*c0+i*c1<=x; ans+=c*(j*c0+i*c1))
			tmp+=(c=comb(j,i));
		for(ll j=i; (++j)*c1+i*c0<=x; ans+=c*(j*c1+i*c0))
			tmp+=(c=comb(j,i));
	}
}
int main(){
	scanf("%lld%lld%lld",&n,&c0,&c1);
	--n,c0>c1&&(swap(c0,c1),1);
	if(!c0){
		printf("%lld\n",n*c1);
		return 0;
	}
	ll l=0,r=c1*26,mid;
    while(l<=r){
        mid=(l+r)>>1;
        if(check(mid))r=mid-1;
        else l=mid+1;
    }
    ll c,s;
    work(l-1,c,s);
    s+=(n-c)*l+n*(c0+c1);
    printf("%lld\n",s);
    return 0;
}

#include <cstdio>
#include <algorithm>
#define inf 2147483647
using namespace std;
typedef long long ll;
ll c0,c1,n;
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
ll lls[31];
ll comb(ll a,ll b){
    ll s=1,x,g;
    for(ll i=0; ++i<=b; lls[i]=i);
    for(ll i=-1; ++i<b; ){
    	x=a+b-i;
    	for(ll j=0; ++j<=b; ){
    		g=gcd(lls[j],x);
    		x/=g;
    		lls[j]/=g;
		}
		if(x>inf/s)
			return inf;
		s*=x;
	}
    return s;
}
bool check(ll x){
	ll tmp=x/c0+x/c1+1;
	if(tmp>n)
    	return 1;
    for(ll i=0; ++i<=26; ){
		for(ll j=i-1; (++j)*c0+i*c1<=x; )
			if((tmp+=comb(j,i))>n)
				return 1;
		for(ll j=i; (++j)*c1+i*c0<=x; )
			if((tmp+=comb(j,i))>n)
				return 1;
	}
	return 0;
}
void work(ll x,ll &tmp,ll &ans){
	tmp=x/c0+x/c1+1;
	ans=((x/c0)*(x/c0+1)*c0+(x/c1)*(x/c1+1)*c1)>>1;
	ll c;
	for(int i=0; ++i<=26; ){
		for(ll j=i-1; (++j)*c0+i*c1<=x; ans+=c*(j*c0+i*c1))
			tmp+=(c=comb(j,i));
		for(ll j=i; (++j)*c1+i*c0<=x; ans+=c*(j*c1+i*c0))
			tmp+=(c=comb(j,i));
	}
}
int main(){
	scanf("%lld%lld%lld",&n,&c0,&c1);
	--n,c0>c1&&(swap(c0,c1),1);
	if(!c0){
		printf("%lld\n",n*c1);
		return 0;
	}
	ll l=0,r=c1*26,mid;
    while(l<=r){
        mid=(l+r)>>1;
        if(check(mid))r=mid-1;
        else l=mid+1;
    }
    ll c,s;
    work(l-1,c,s);
    s+=(n-c)*l+n*(c0+c1);
    printf("%lld\n",s);
    return 0;
}

#include <cstdio>
#include <algorithm>
#define inf 2147483647
using namespace std;
typedef long long ll;
ll c0,c1,n;
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
ll lls[31];
ll comb(ll a,ll b){
    ll s=1,x,g;
    for(ll i=0; ++i<=b; lls[i]=i);
    for(ll i=-1; ++i<b; ){
    	x=a+b-i;
    	for(ll j=0; ++j<=b; ){
    		g=gcd(lls[j],x);
    		x/=g;
    		lls[j]/=g;
		}
		if(x>inf/s)
			return inf;
		s*=x;
	}
    return s;
}
bool check(ll x){
	ll tmp=x/c0+x/c1+1;
	if(tmp>n)
    	return 1;
    for(ll i=0; ++i<=26; ){
		for(ll j=i-1; (++j)*c0+i*c1<=x; )
			if((tmp+=comb(j,i))>n)
				return 1;
		for(ll j=i; (++j)*c1+i*c0<=x; )
			if((tmp+=comb(j,i))>n)
				return 1;
	}
	return 0;
}
void work(ll x,ll &tmp,ll &ans){
    tmp=x/c0+x/c1+1;
    ans=((x/c0)*(x/c0+1)*c0+(x/c1)*(x/c1+1)*c1)>>1;
    ll c;
    for(ll i=1;i<=26;++i){
        for(ll j=i;j*c0+i*c1<=x;++j){
            c=comb(j,i);
            tmp+=c;
            ans+=c*(j*c0+i*c1);
        }
        for(ll j=i+1;j*c1+i*c0<=x;++j){
            c=comb(j,i);
            tmp+=c;
            ans+=c*(j*c1+i*c0);
        }
    }
}
//void work(ll x,ll &tmp,ll &ans){
//	tmp=x/c0+x/c1+1;
//	ans=((x/c0)*(x/c0+1)*c0+(x/c1)*(x/c1+1)*c1)>>1;
//	ll c;
//	for(int i=0; ++i<=26; ){
//		for(ll j=i-1; (++j)*c0+i*c1<=x; ans+=c*(j*c0+i*c1))
//			tmp+=(c=comb(j,i));
//		for(ll j=i; (++j)*c1+i*c0<=x; ans+=c*(j*c0+i*c1))
//			tmp+=(c=comb(j,i));
//	}
//}
int main(){
	scanf("%lld%lld%lld",&n,&c0,&c1);
	--n,c0>c1&&(swap(c0,c1),1);
	if(!c0){
		printf("%lld\n",n*c1);
		return 0;
	}
	ll l=0,r=c1*26,mid;
    while(l<=r){
        mid=(l+r)>>1;
        if(check(mid))r=mid-1;
        else l=mid+1;
    }
    ll c,s;
    work(l-1,c,s);
    s+=(n-c)*l+n*(c0+c1);
    printf("%lld\n",s);
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
ll ans;
int n,a,b,S;
int c[20005];
bool check(ll m){
	int sum=m/a;
	For(i,0,S) c[i]=i+1;
	for (int i=1;1ll*i*b<=m&&sum<n;++i)
		for (int j=0;1ll*i*b+1ll*j*a<=m&&sum<n;j++)
			sum+=c[j],c[j]+=(j?c[j-1]:0);
	return sum>=n;
}
void calc(ll m){
	int sum=m/a;
	ans+=1ll*sum*(sum+1)/2*a;
	For(i,0,S) c[i]=i+1;
	for (int i=1;1ll*i*b<=m;++i)
		for (int j=0;1ll*i*b+1ll*j*a<=m;j++){
			ans+=1ll*c[j]*(1ll*i*b+1ll*j*a);
			sum+=c[j],c[j]+=(j?c[j-1]:0);
		}
	//cout<<ans<<' '<<sum<<' '<<m<<endl;
	ans-=m*(sum-n);
}
int main(){
	scanf("%d%d%d",&n,&a,&b);
	if (a>b) swap(a,b);
	n--; ans=1ll*n*(a+b);
	n--; S=sqrt(n*2)+1;
	if (!a) return printf("%lld\n",ans),0;
	ll l=0,r=1ll*n*a,p;
	while (l<=r){
		ll mid=(l+r)/2;
		if (check(mid)) p=mid,r=mid-1;
		else l=mid+1;
	}
	calc(p);
	printf("%lld\n",ans);
}

#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x+=y;if(x>=mod) x-=mod;}
inline void read(int &x){
	x=0;char ch=getchar();
	while(ch>'9'||ch<'0') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
}

int n,c0,c1;
ll ans=0;
set<ll> s;
map<ll,ll> f;

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
	srand(time(0));
	time_tester(0);
#endif
	scanf("%d%d%d",&n,&c0,&c1);
	n--;
	s.insert(0);
	f[0]=1;
	while(n>0){
		ll x=*s.begin(),p=min((ll)n,f[x]);
		s.erase(s.begin());
//		debug(x);debug(p);
		ans+=(c0+c1+x)*p;
		f[x+c0]+=p;f[x+c1]+=p;
		s.insert(x+c0);s.insert(x+c1);
		n-=p;
	}
	printf("%I64d\n",ans);
#ifdef rqgao2014
	time_tester(1);
#endif
	return 0;
}

//lxrtxdy!
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

map < LL, LL > M;

int main()
{
	ios_base::sync_with_stdio(0);
	LL n, a, b;
	cin >> n >> a >> b;
	if(min(a, b) == 0)
	{
		LL res = max(a, b) * (n - 1);
		cout << res << "\n";
		return 0;
	}
	M[0] = 1; n--;
	while(n > 0)
	{
		auto x = *M.begin();
		if(x.second <= n)
		{
			n -= x.second;
			M.erase(M.begin());
			M[x.first + a] += x.second;
			M[x.first + b] += x.second;
		}
		else
		{
			M[x.first] -= n;
			M[x.first + a] += n;
			M[x.first + b] += n;
			n = 0;
		}
	}
	LL ans = 0;
	for(auto x: M)
		ans += x.second * x.first;
	cout << ans << "\n";
	return 0;
}//hellobig_tq
//orzlxr!

#include <bits/stdc++.h>

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

#define K 40

using namespace std;

typedef long long ll;
int n;
ll c0, c1;

ll f[K];

long double chsfp(ll a, int b) {
    if (a < b) return 0;
    long double lg = 0;
    FO(i,0,b) lg += log((long double)a-i) - log((long double)i+1);
    return exp(lg);
}

long long gn(ll x) {
    FO(i,0,K) {
        // take i of c1
        ll nx = x - i*c1;
        // n0 * c0 <= nx
        // n0 <= nx / c0
        ll n0 = nx >= 0 ? nx / c0 : -1;
        f[i] = n0;
    }
    long double fpres = 0;
    FO(i,1,K) {
        fpres += chsfp(f[i]+i,i);
        fpres += chsfp(f[i-1]+i,i) - chsfp(f[i]+i,i);
    }
    if (fpres > 1e10) return 1e10;
    else return (long long) (fpres + 0.5);
}

ll stk[10000000];
int ss;

int main() {
    scanf("%d %lld %lld", &n, &c0, &c1);
    if (c1 < c0) swap(c1,c0);
    // c0 <= c1
    //printf("%lld %lld\n", c0, c1);
    if (c0 == 0) {
        printf("%lld\n", (n-1)*c1);
        return 0;
    }
    ll sx = 0, ex = 1e10, bx = 1e10;
    while (sx <= ex) {
        ll mx = (sx+ex)/2;
        long long m = gn(mx);
        if (m >= n) {
            ex = mx-1;
            bx = mx;
        } else {
            sx = mx+1;
        }
    }
    //printf("bx=%lld\n", bx);
    stk[ss++] = 0;
    ll res = 0;
    int nmtk = 0;
    while (ss) {
        ll f = stk[--ss];

        ll a = f+c0, b = f+c1;
        if (a < bx) stk[ss++] = a;
        else {
            res += a;
            nmtk++;
        }
        if (b < bx) stk[ss++] = b;
        else {
            res += b;
            nmtk++;
        }
    }
    while (nmtk < n) {
        res -= bx;
        res += bx+c0;
        res += bx+c1;
        nmtk++;
    }

    printf("%lld\n", res);
}

#include <stdio.h>
#include <string.h>
#include <bitset>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)

typedef long long ll;

ll n,c0,c1;

ll cnk(ll n, ll k)
{
	ll res=1;
	for(int i=1;i<=k;i++)
		res=res*(n-i+1)/i;
	return res;
}

ll count(ll x)
{
	ll res=0;
	for(int j=0;(1<<j)<=n;j++)
	{
		if(x<j*c1) break;
		ll l=(x-j*c1)/c0;
		res+=cnk(j+l+1,j+1);
	}
	return res;
}

ll get_cost(ll x)
{
	ll res=0;
	for(int j=0;(1<<j)<=n;j++)
	{
		if(x<j*c1) break;
		ll l=(x-j*c1)/c0;
		res+=l*(l+1)*cnk(j+l+1,j)/(j+2)*c0+j*c1*cnk(j+l+1,j+1);
	}
	return res;
}

int main()
{
	cin>>n>>c0>>c1;
	if(c0==0 || c1==0)
		printf("%lld\n",(c0+c1)*(n-1));
	else
	{
		if(c0>c1) swap(c0,c1);
		n--;
		ll l=1;
		ll r=1;
		while(count(r)<n)
			r*=2;
		while(l<r)
		{
			ll c=(l+r)/2;
			if(count(c)<n)
				l=c+1;
			else
				r=c;
		}
		ll res=(c0+c1)*n;
		res+=(n-count(r-1))*r;
		res+=get_cost(r-1);
		cout<<res<<endl;
	}
	return 0;
}

//#ifndef LOCAL
//#define NDEBUG
//#endif

#include <bits/stdc++.h>
using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  for (auto it = d.b; it != d.e; ++it)
    *this << ", \0[" + 3 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};

#define imie(x) "[" << #x ": " << (x) << "] "

const int nax=100;
const int dax=50*1000;

int n;
long long c0, c1;

int roz[nax+2];
vector <int> wek[nax+2];
int gdz;

long long wyn;

int main()
{
	srand(time(0));
	scanf("%d%lld%lld", &n, &c0, &c1);

	n--;
	if (c0>c1)
		swap(c0, c1);

	for (int i=1; i<=nax; i++)
		wek[i].resize(dax, 0);

	wyn=n*(c0+c1);
	while(n)
	{
		int bes=0;
		long long tam=c0*gdz;
		for (int i=1; wek[i][roz[i]]; i++)
		{
			if (i*c1+roz[i]*c0<tam)
			{
				tam=i*c1+roz[i]*c0;
				bes=i;
			}
		}
		if (!bes)
		{
			if (gdz<dax)
				wek[1][gdz]++;
			gdz++;
			n--;
			wyn+=tam;
		}
		else
		{
			int x=min(n, wek[bes][roz[bes]]);
			wek[bes][roz[bes]]=0;
			wek[bes][roz[bes]+1]+=x;
			wek[bes+1][roz[bes]]+=x;
			roz[bes]++;
			n-=x;
			wyn+=tam*x;
		}
	}
	printf("%lld\n", wyn);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

map<LL,LL>M;

int main()
{
ios_base::sync_with_stdio(0);
LL n,a,b;
cin>>n>>a>>b;
if(min(a,b)==0)
{
LL res=max(a,b)*(n-1);
cout<<res<<"\n";
return 0;
}
M[0]=1;n--;
while(n>0)
{
auto x=*M.begin();
if(x.second<=n)
{
n-=x.second;
M.erase(M.begin());
M[x.first+a]+=x.second;
M[x.first+b]+=x.second;
}
else
{
M[x.first]-=n;
M[x.first+a]+=n;
M[x.first+b]+=n;
n=0;
}
}
LL ans=0;
for(auto x: M)
ans+=x.second*x.first;
cout<<ans<<"\n";
return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

map < LL, LL > M;

int main()
{
	ios_base::sync_with_stdio(0);
	LL n, a, b;
	cin >> n >> a >> b;
	if(min(a, b) == 0)
	{
		LL res = max(a, b) * (n - 1);
		cout << res << "\n";
		return 0;
	}
	M[0] = 1; n--;
	while(n > 0)
	{
		auto x = *M.begin();
		if(x.second <= n)
		{
			n -= x.second;
			M.erase(M.begin());
			M[x.first + a] += x.second;
			M[x.first + b] += x.second;
		}
		else
		{
			M[x.first] -= n;
			M[x.first + a] += n;
			M[x.first + b] += n;
			n = 0;
		}
	}
	LL ans = 0;
	for(auto x: M)
		ans += x.second * x.first;
	cout << ans << "\n";
	return 0;
}//hellobig_tq

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

typedef long long ll;
const int N = 20000;
ll c0, c1;
ll n;
ll C[N];

bool check(ll x)
{
	ll cnt = (x / c0) + 1;
	for (int i = 0; i < N; i++)
		C[i] = i + 1;
	for (int i = 1; cnt < n && i * c1 <= x; i++)
	{
		for (int j = 0; cnt < n && j * c0 + i * c1 <= x; j++)
		{
			cnt += C[j];
			if (j > 0)
				C[j] += C[j - 1];
		}
	}
	return cnt >= n;
}

ll solve(ll x)
{
	ll cnt = (x / c0) + 1;
	ll sum = cnt * (cnt - 1) / 2 * c0;
	for (int i = 0; i < N; i++)
		C[i] = i + 1;
	for (int i = 1; i * c1 <= x; i++)
	{
		for (int j = 0; j * c0 + i * c1 <= x; j++)
		{
			cnt += C[j];
			sum += C[j] * (j * c0 + i * c1);
			if (j > 0)
				C[j] += C[j - 1];
		}
	}
	return sum - (cnt - n) * x;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%lld%lld%lld", &n, &c0, &c1);
	if (c0 > c1) swap(c0, c1);
	n--;
	ll ans = n * (c0 + c1);
	if (n == 1 || c0 == 0)
	{
		printf("%lld\n", ans);
		return 0;
	}
	ll l = 0, r = c0 * n;
	while(r - l > 1)
	{
		ll x = (l + r) / 2;
		if (check(x))
			r = x;
		else
			l = x;
	}
	ans += solve(r);
	printf("%lld\n", ans);

	return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
#define CT printf("\n--------------------\n");
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
template<class _Tp>void ckmax(_Tp &a,_Tp b){if(a<b) a=b;}
template<class _Tp>void ckmin(_Tp &a,_Tp b){if(a>b) a=b;}
template<class _Tp>_Tp gcd(_Tp a,_Tp b){return (b==0)?(a):(gcd(b,a%b));}
int read(){
	char ch=getchar();bool f=1;int x=0;
	while((ch<'0' || ch>'9') && ch!='-') ch=getchar();
	if(ch=='-') f=0,ch=getchar();
	while(ch>='0' && ch<='9'){x=x*10+(ch&15);ch=getchar();}
	return f?x:-x;
}
const int inf=1000000000;
const ll Inf=1000000000000000000ll;
ll ans;
int n,a,b,s;
int c[20005];
bool check(ll m){
	int sum=m/a;
	for(int i=0;i<=s;++i)
		c[i]=i+1;
	for(int i=1;1ll*i*b<=m&&sum<n;++i)
		for(int j=0;1ll*i*b+1ll*j*a<=m&&sum<n;++j)
			sum+=c[j],c[j]+=(j?c[j-1]:0);
	return sum>=n;
}
void calc(ll m){
	int sum=m/a;
	ans+=1ll*sum*(sum+1)/2*a;
	for(int i=0;i<=s;++i)
		c[i]=i+1;
	for(int i=1;1ll*i*b<=m;++i)
		for(int j=0;1ll*i*b+1ll*j*a<=m;++j){
			ans+=1ll*c[j]*(1ll*i*b+1ll*j*a);
			sum+=c[j],c[j]+=(j?c[j-1]:0);
		}
	ans-=m*(sum-n);
}
int main(){
	n=read();a=read();b=read();
	if(a>b) swap(a,b);
	n--;
	ans=1ll*n*(a+b);
	n--;
	s=sqrt(n*2)+1;
	if(!a){
		printf("%lld\n",ans);
		return 0;
	}
	ll l=0,r=1ll*n*a;
	while(l<r){
		ll mid=(l+r)/2;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	calc(l);
	printf("%lld\n",ans);
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ans;
int n,a,b,s;
int c[20005];
bool check(ll m){
	int sum=m/a;
	for (int i=0;i<=s;i++) c[i]=i+1;
	for (int i=1;1ll*i*b<=m&&sum<n;i++)
		for (int j=0;1ll*i*b+1ll*j*a<=m&&sum<n;j++)
			sum+=c[j],c[j]+=(j?c[j-1]:0);
	return sum>=n;
}
void calc(ll m){
	int sum=m/a;
	ans+=1ll*sum*(sum+1)/2*a;
	for (int i=0;i<=s;i++) c[i]=i+1;
	for (int i=1;1ll*i*b<=m;i++)
		for (int j=0;1ll*i*b+1ll*j*a<=m;j++){
			ans+=1ll*c[j]*(1ll*i*b+1ll*j*a);
			sum+=c[j],c[j]+=(j?c[j-1]:0);
		}
	ans-=m*(sum-n);
}
int main(){
	scanf("%d%d%d",&n,&a,&b);
	if (a>b) swap(a,b);
	n--; ans=1ll*n*(a+b);
	n--; s=sqrt(n*2)+1;
	if (!a){
		printf("%lld\n",ans);
		return 0;
	}
	ll l=0,r=1ll*n*a;
	while (l<r){
		ll mid=(l+r)/2;
		if (check(mid)) r=mid;
		else l=mid+1;
	}
	calc(l);
	printf("%lld\n",ans);
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

const ll MXL = 0x3f3f3f3f3f3f3f3fLL;

ll lim = 20006;
ll n;
ll a, b;

vector<pair<ll,ll>> p; // {index, sum}
multiset<ll> s;

void ini() {
	p = {{0, 0}};
	s = {0};
	for (int i = 0; i < lim; ++i) {
		ll t = *s.begin();
		s.erase(s.begin());
		p.pb({t + b, -t + (t + a) + (t + b)});
		s.insert(t + a);
		s.insert(t + b);
	}
	ll pre = 0;
	for (auto &i : p)
		i.second = pre += i.second;
}

ll count(ll deep) {
	if (deep <= p.back().first)
		return upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)) - p.begin();
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		re += upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)) - p.begin();
	}
}

ll sum(ll deep) {
	if (deep <= p.back().first)
		return prev(upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)))->second;
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		auto t = prev(upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)));
		re += t->second + (t - p.begin()) * i;
		if (re > MXL)
			return MXL;
	}
}

ll getDeep() {
	ll L = 0, R = p.back().first * p.back().first, M;
	while (L < R)
		if (M = L + R >> 1, count(M) >= n)
			R = M;
		else
			L = M + 1;
	return L;
}

int main() {
	cin >> n >> a >> b;
	if (a > b) swap(a, b);

	ini();

	ll h = getDeep();

	ll c = count(h);
	ll ans = sum(h);
	if (c > n)
		ans -= (c - n) * (h + (h - b + a) - (h - b));

	cout << ans << endl;

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

const ll MXL = 0x3f3f3f3f3f3f3f3fLL;

ll lim = 100006;
ll n;
ll a, b;

vector<pair<ll,ll>> p; // {index, sum}
multiset<ll> s;

void ini() {
	p = {{0, 0}};
	s = {0};
	for (int i = 0; i < lim; ++i) {
		ll t = *s.begin();
		s.erase(s.begin());
		p.pb({t + b, -t + (t + a) + (t + b)});
		s.insert(t + a);
		s.insert(t + b);
	}
	ll pre = 0;
	for (auto &i : p)
		i.second = pre += i.second;
}

ll count(ll deep) {
	if (deep <= p.back().first)
		return upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)) - p.begin();
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		re += upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)) - p.begin();
		re = min(re, MXL);
	}
	return re;
}

ll sum(ll deep) {
	if (deep <= p.back().first)
		return prev(upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)))->second;
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		auto t = prev(upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)));
		re += t->second + (t - p.begin()) * i;
		assert(re < MXL);
	}
	return re;
}

ll getDeep() {
	ll L = 0, R = MXL, M;
	while (L < R)
		if (M = L + R >> 1, count(M) >= n)
			R = M;
		else
			L = M + 1;
	return L;
}

int main() {
	cin >> n >> a >> b;
	if (a > b) swap(a, b);

	ini();

	ll h = getDeep();

	ll c = count(h);
	ll ans = sum(h);
	if (c > n)
		ans -= (c - n) * (h + (h - b + a) - (h - b));

	cout << ans << endl;

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

const ll MXL = 0x3f3f3f3f3f3f3f3fLL;

ll lim = 50006;
ll n;
ll a, b;

vector<pair<ll,ll>> p; // {index, sum}
multiset<ll> s;

void ini() {
	p = {{0, 0}};
	s = {0};
	for (int i = 0; i < lim; ++i) {
		ll t = *s.begin();
		s.erase(s.begin());
		p.pb({t + b, -t + (t + a) + (t + b)});
		s.insert(t + a);
		s.insert(t + b);
	}
	ll pre = 0;
	for (auto &i : p)
		i.second = pre += i.second;
}

ll count(ll deep) {
	if (deep <= p.back().first)
		return upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)) - p.begin();
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		re += upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)) - p.begin();
		re = min(re, MXL);
	}
	return re;
}

ll sum(ll deep) {
	if (deep <= p.back().first)
		return prev(upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)))->second;
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		auto t = prev(upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)));
		re += t->second + (t - p.begin()) * i;
		assert(re < MXL);
	}
	return re;
}

ll getDeep() {
	ll L = 0, R = MXL, M;
	while (L < R)
		if (M = L + R >> 1, count(M) >= n)
			R = M;
		else
			L = M + 1;
	return L;
}

int main() {
	cin >> n >> a >> b;
	if (a > b) swap(a, b);

	ini();

	ll h = getDeep();

	ll c = count(h);
	ll ans = sum(h);
	if (c > n)
		ans -= (c - n) * (h + (h - b + a) - (h - b));

	cout << ans << endl;

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

const ll MXL = 0x3f3f3f3f3f3f3f3fLL;

ll lim = 40006;
ll n;
ll a, b;

vector<pair<ll,ll>> p; // {index, sum}
multiset<ll> s;

void ini() {
	p = {{0, 0}};
	s = {0};
	for (int i = 0; i < lim; ++i) {
		ll t = *s.begin();
		s.erase(s.begin());
		p.pb({t + b, -t + (t + a) + (t + b)});
		s.insert(t + a);
		s.insert(t + b);
	}
	ll pre = 0;
	for (auto &i : p)
		i.second = pre += i.second;
}

ll count(ll deep) {
	if (deep <= p.back().first)
		return upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)) - p.begin();
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		re += upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)) - p.begin();
	}
}

ll sum(ll deep) {
	if (deep <= p.back().first)
		return prev(upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)))->second;
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		auto t = prev(upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)));
		re += t->second + (t - p.begin()) * i;
		if (re > MXL)
			return MXL;
	}
}

ll getDeep() {
	ll L = 0, R = p.back().first * p.back().first, M;
	while (L < R)
		if (M = L + R >> 1, count(M) >= n)
			R = M;
		else
			L = M + 1;
	return L;
}

int main() {
	cin >> n >> a >> b;
	if (a > b) swap(a, b);

	ini();

	ll h = getDeep();

	ll c = count(h);
	ll ans = sum(h);
	if (c > n)
		ans -= (c - n) * (h + (h - b + a) - (h - b));

	cout << ans << endl;

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

const ll MXL = 0x3f3f3f3f3f3f3f3fLL;

ll lim = 100006;
ll n;
ll a, b;

vector<pair<ll,ll>> p; // {index, sum}
multiset<ll> s;

void ini() {
	p = {{0, 0}};
	s = {0};
	for (int i = 0; i < lim; ++i) {
		ll t = *s.begin();
		s.erase(s.begin());
		p.pb({t + b, -t + (t + a) + (t + b)});
		s.insert(t + a);
		s.insert(t + b);
	}
	ll pre = 0;
	for (auto &i : p)
		i.second = pre += i.second;
}

ll count(ll deep) {
	if (deep <= p.back().first)
		return upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)) - p.begin();
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		re += upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)) - p.begin();
	}
}

ll sum(ll deep) {
	if (deep <= p.back().first)
		return prev(upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)))->second;
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		auto t = prev(upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)));
		re += t->second + (t - p.begin()) * i;
		assert(re < MXL);
	}
}

ll getDeep() {
	ll L = 0, R = MXL, M;
	while (L < R)
		if (M = L + R >> 1, count(M) >= n)
			R = M;
		else
			L = M + 1;
	return L;
}

int main() {
	cin >> n >> a >> b;
	if (a > b) swap(a, b);

	ini();

	ll h = getDeep();

	ll c = count(h);
	ll ans = sum(h);
	if (c > n)
		ans -= (c - n) * (h + (h - b + a) - (h - b));

	cout << ans << endl;

	return 0;
}

/* Author haleyk10198 */
/* �@��:  haleyk10198 */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define MOD 1000000007
#define LINF (1LL<<60)
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))

using namespace std;
using namespace __gnu_pbds;

int n,c1,c2,now;
ll tt;
map<int,int> cnt;

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//ios_base::sync_with_stdio(false);
	cin>>n>>c1>>c2;
	if(c1>c2)
		swap(c1,c2);
	if(n==1){
		cout<<c1<<endl;
		return 0;
	}
	else if(c1==0){
		cout<<1LL*(n-1)*c2<<endl;
		return 0;
	}
	cnt[0]=now=1;
	while(now<n){
		auto x=cnt.begin();
		if(now+x->second>=n){
			tt+=1LL*(n-now)*(c1+c2);
			tt+=1LL*(x->first)*(n-now);
			break;
		}
		else{
			now+=x->second;
			tt+=x->first*x->second;
			tt+=1LL*x->second*(c1+c2);
			cnt[x->first+c1]+=x->second;
			cnt[x->first+c2]+=x->second;
			cnt.erase(x->first);
		}
	}
	cout<<tt<<endl;
	return 0;
}

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
typedef long long LL;

map<LL,int>mp; map<LL,int>::iterator it;
int main()
{
	int n,c0,c1;
	scanf("%d%d%d",&n,&c0,&c1);
	if(c0==0||c1==0){puts("0");return 0;}

	mp[0]=1;int u=n-1;
	it=mp.begin();
	while(1)
	{
		if(u>it->second)
			mp[it->first+c0]+=it->second,mp[it->first+c1]+=it->second;
		else
		{
			mp[it->first+c0]+=u,mp[it->first+c1]+=u;
			it->second-=u;
			break;
		}
		u-=it->second;
		it++;
	}
	LL ans=0;
	for(;it!=mp.end();it++)
		ans+=(it->first)*(it->second);
	printf("%lld\n",ans);

	return 0;
}

//============================================================================
// Name        : contest.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
#include <tuple>
using namespace std;

#ifdef TEAM
#define dbg2(x, y) cout << #x" = " << x << "; " << #y" = " << y << endl;
#define dbg(x) cout << #x" = " << x << endl;
#else
#define dbg2(...) void(0);
#define dbg(...) void(0);
#endif

#define ALL(v) (v).begin(), (v).end()

typedef long long int llint;
typedef pair<int, int> pii;
void solve();

int main() {
#define FILENAME "division"
#ifdef TEAM
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen(FILENAME".in", "r", stdin);
	//freopen(FILENAME".out", "w", stdout);
#endif

	solve();

	return 0;
}

void solve(){
	int n; cin >> n;
	llint c[2]; cin >> c[0] >> c[1];
	if (c[0] > c[1]) swap(c[0], c[1]);
	if (c[0] == 0){
		cout << n / 2 * c[1];
		return;
	}
	map<llint, int> path;
	path[c[0]] += 1;
	path[c[1]] += 1;
	int sum = 2;
	while (sum < n){
		llint cost; int cnt;
		tie(cost, cnt) = *path.begin();
		dbg2(cost, cnt);
		dbg(sum);
		path.erase(path.begin());
		int add = min(cnt, n - sum);
		path[cost+c[0]] += add;
		path[cost+c[1]] += add;
		if (add < cnt){
			path[cost] = cnt - add;
		}
		sum += add;
	}
	cout << accumulate(ALL(path), 0LL, [](llint x, pair<llint, int> p){
		return x + p.first * p.second;
	});
}

#include <bits/stdc++.h>
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

void solve() {
	int n, c[2]; cin >> n >> c[0] >> c[1];
	sort(c, c + 2);
	map<long long, int> hs;
	hs[c[0]] = hs[c[1]] = 1;
	long long ans = c[0] + c[1];
	int tot = 2;
	while (tot < n) {
		pair<long long, int> x = *hs.begin();
		hs.erase(x.fi);
		hs[x.fi + c[0]] += x.se;
		int tmp = min(n - tot, x.se);
		hs[x.fi + c[1]] += tmp;
		ans += tmp * (x.fi + c[0] + c[1]);
		tot += tmp;
	}
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

struct CompressedVector {
	int size = 0;
	int tam = 0;
	pair<int,int> v[1000];
	inline int at(int idx, int &hint) const {
		while (hint+1 < tam && v[hint+1].first == idx) hint++;
		return v[hint].second;
	}
	inline void push_back(int x) {
		++size;
		if (!tam || v[tam-1].second != x) v[tam++] = {size, x};
	}
};

CompressedVector dp;
int n, c0, c1;

void solve() {
	scanf("%d %d %d", &n, &c0, &c1);

	dp.push_back(0);
	dp.push_back(c0+c1);

	int zero = 1;
	int zero_hint = 1;
	int one = 1;
	int one_hint = 1;
	long long zero_diff = c0+c1;
	long long one_diff = c0+c1;
	long long last_diff = c0+c1;

	for (int i = 3; i <= n; i++) {
		long long inc_one = one_diff + c1;
		long long inc_zero = zero_diff + c0;

		if (inc_zero < inc_one) {
			last_diff = inc_zero;
			dp.push_back( inc_zero - last_diff );
			zero++;
			zero_diff += dp.at( zero+1, zero_hint );
		}
		else {
			last_diff = inc_one;
			dp.push_back( inc_one - last_diff );
			one++;
			one_diff += dp.at( one+1, one_hint );
		}
	}

	long long ans = 0;
	long long diff = 0;
	int diff_hint = 1;
	for (int idx = 2; idx <= n; idx++) {
		diff += dp.at(idx, diff_hint);
		ans += diff;
	}

	printf("%lld\n", ans);
}

int main() {
    solve();
}

#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n, m, r, a, b, k;
    cin >> n >> a >> b;
    if(min(a, b) == 0)
	{
        long long res = max(a, b) * (n - 1);
		cout << res << "\n";
		return 0;
	}
    map < long long, long long > mp;
    mp[0] = 1;
    n--;
    while (n){
        long long cost = mp.begin() -> first;
        long long  cnt = mp.begin() -> second;
        if (cnt <= n)
            mp.erase(mp.begin());
        else
            mp[cost] -= n;
        int erased = min ((long long )n, cnt);
        mp[a+cost]+= erased;
        mp[b+cost]+= erased;
        n -= erased;
    }
    long long ans = 0;
    for(auto it : mp)
        ans += it.first * it.second;
    cout << ans ;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n, m, r, a, b, k;
    cin >> n >> a >> b;
    if(min(a, b) == 0)
	{
        long long res = max(a, b) * (n - 1);
		cout << res << "\n";
		return 0;
	}
    map < long long, int > mp;
    mp[0] = 1;
    n--;
    while (n){
        long long cost = mp.begin() -> first;
        int cnt = mp.begin() -> second;
        if (cnt <= n)
            mp.erase(mp.begin());
        else
            mp[cost] -= n;
        int erased = min (n, cnt);
        mp[a+cost]+= erased;
        mp[b+cost]+= erased;
        n -= erased;
    }
    long long ans = 0;
    for(auto it : mp)
        ans += it.first * it.second;
    cout << ans ;
    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
set<PR> Set;
int n,c0,c1,num,ans;
void add(int x,int y)
{
	set<PR>::iterator it=Set.lower_bound(MP(x,0));
	if (it!=Set.end()&&(*it).fi==x) y+=(*it).se,Set.erase(it);
	Set.insert(MP(x,y));
}
signed main()
{
	n=read(),c0=read(),c1=read();
	if (c0>c1) swap(c0,c1);
	if (!c1) { puts("0"); return 0; }
	if (!c0) { printf("%lld\n",1ll*(n-1)*c1); return 0; }
	Set.insert(MP(0,1)),num=1,ans=0;
	while (num<n)
	{
		int x=(*Set.begin()).fi,y=(*Set.begin()).se;
		Set.erase(Set.begin());
		upmin(y,n-num);
		num+=y,ans+=1ll*(c0+c1)*y+1ll*x*y;
		add(x+c0,y),add(x+c1,y);
	}
	printf("%d\n",ans);
	return 0;
}

#include <bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int) (x).size())
#define ALL(x) x.begin(), x.end()

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef unsigned long long u64;
typedef vector<int> VI;

template <typename T> inline bool cmin(T & a, const T & b) { return a > b ? a = b, 1 : 0;}
template <typename T> inline bool cmax(T & a, const T & b) { return a < b ? a = b, 1 : 0;}

int read() {
	int x = 0, f = 1;char ch;
	for (ch = getchar(); !isdigit(ch); ch = getchar())
		if (ch == '-') f = -1;
	for (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return x * f;
}

int main() {
	LL n, c0, c1;
	cin >> n >> c0 >> c1;
	map<LL, LL> F;
	for (F[0] = 1, --n; n > 0; ) {
		pair<LL, LL> cur = *F.begin();
		if(cur.se <= n) {
			F.erase(F.begin());
			F[cur.fi + c0] += cur.se;
			F[cur.se + c1] += cur.se;
		} else {
			F[cur.fi] -= n;
			F[cur.fi + c0] += n;
			F[cur.fi + c1] += n;
		}
		n -= cur.se;
	}
	LL ans = 0;
	for (auto x : F)
		ans += x.fi * x.se;
	cout << ans << endl;
	return 0;
}

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ());

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

int n, a, b;

int read() {
  if (scanf("%d%d%d", &n, &a, &b) < 3) {
    return 0;
  }
  return 1;
}

long long res;

long long get(long long p, bool countr = 0) {
  res = 0;
  long long cnt = 0;
  for (int i = 0; p >= 0ll; ++i, p -= b) {
    long long k = p / a;

    long long N = i + 1 + k;
    long long K = min(k, N - k);
    long long c = 1;
    for (int j = 1; j <= K; ++j) {
      c *= N - j + 1;
      c /= j;
      if (c > 1e16) {
        break;
      }
    }
    cnt += c;
    if (countr) {
      res += c * b * i;
      c = 1;
      for (int j = 1; j <= k; ++j) {
        c *= j + i;
        c /= j;
        res += c * a * j;
      }
    }
  }
  return cnt;
}

void solve() {
  if (a > b) {
    swap(a, b);
  }
  if (!a) {
    printf("0\n");
    return;
  }
  long long left = -1, right = b * 30ll;
  while (left + 1 < right) {
    auto mid = (left + right) / 2;

    if (get(mid) >= n - 1) {
      right = mid;
    } else {
      left = mid;
    }
  }
  auto got = get(right, 1);
  res -= (got - n + 1) * right;
  res += (long long) (a + b) * (n - 1);
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 10000005, M = 1005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int c[M+3][M+3];

ll a, b;

ll con(int x, int y) {
  if (x < M) return c[x][y];
  if (y == 0) return 1;
  if (y == 1) return x;
  if (y == 2) return ll(x-1)*x/2;
  return INF;
}
bool f(ll x, ll n) {
  ll pre = -1;
  for (ll i = x/a; i >= 0; --i) {
    ll j = (x-a*i)/b;
    ll s = con(i+j,j);
    n -= s;
    if (pre != j) n -= s;
    if (n < 0) return false;
    pre = j;
  }
  return true;
}

ll rst;
ll g(ll x) {
  rst = 0;
  ll res = 0;
  ll pre = -1;
  for (ll i = x/a; i >= 0; --i) {
    ll j = (x-a*i)/b;
    ll s = con(i+j,j);
    ll t = pre!=j?2:1;
    rst += s*t;
    res += s*(a*i+b*j)*t+b;
    if (pre != j) res += a;
    pre = j;
  }
  return res;
}

int main() {
  c[0][0] = 1;
  rep(i,M) {
    rep(j,i+1) c[i+1][j] += c[i][j], c[i+1][j+1] += c[i][j];
    rep(j,i+2) mins(c[i+1][j], INF);
  }
  int n;
  cin >> n >> a >> b;
  if (a > b) swap(a,b);
  if (!a) {
    cout<<b*n<<endl;
    return 0;
  }
  ll l = 0, r = a*n+1;
  while (l+1<r) {
    ll md = (l+r)>>1;
    if (f(md,n)) l = md; else r = md;
  }
  ll ans = g(l);
  n -= rst;
  ans += n*(r+a+b);
  cout<<ans<<endl;
  return 0;
}

#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 10000005, M = 1005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int c[M+3][M+3];

ll a, b;

ll con(int x, int y) {
  if (x < M) return c[x][y];
  if (y == 0) return 1;
  if (y == 1) return x;
  if (y == 2) return ll(x-1)*x/2;
  return INF;
}
bool f(ll x, ll n) {
  ll pre = -1;
  for (ll i = x/a; i >= 0; --i) {
    ll j = (x-a*i)/b;
    ll s = con(i+j,j);
    n -= s;
    if (pre != j) n -= s;
    if (n < 0) return false;
    pre = j;
  }
  return true;
}

ll rst;
ll g(ll x) {
  rst = 0;
  ll res = 0;
  ll pre = -1;
  for (ll i = x/a; i >= 0; --i) {
    ll j = (x-a*i)/b;
    ll s = con(i+j,j);
    ll t = pre!=j?2:1;
    rst += s*t;
    res += s*(a*i+b*j)*t+b;
    if (pre != j) res += a;
    pre = j;
  }
  return res;
}

int main() {
  c[0][0] = 1;
  rep(i,M) {
    rep(j,i+1) c[i+1][j] += c[i][j], c[i+1][j+1] += c[i][j];
    rep(j,i+2) mins(c[i+1][j], INF);
  }
  int n;
  cin >> n >> a >> b;
  if (a > b) swap(a,b);
  if (!a) {
    cout<<b*(n-1)<<endl;
    return 0;
  }
  ll l = 0, r = b*n+1;
  while (l+1<r) {
    ll md = (l+r)>>1;
    if (f(md,n)) l = md; else r = md;
  }
  ll ans = g(l);
  n -= rst;
  ans += n*(r+a+b);
  cout<<ans<<endl;
  return 0;
}

#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 10000005, M = 1005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int c[M+3][M+3];

ll a, b;

ll con(int x, int y) {
  if (x < M) return c[x][y];
  if (y == 0) return 1;
  if (y == 1) return x;
  if (y == 2) return ll(x-1)*x/2;
  return INF;
}
bool f(ll x, ll n) {
  ll pre = -1;
  for (ll i = x/a; i >= 0; --i) {
    ll j = (x-a*i)/b;
    ll s = con(i+j,j);
    n -= s;
    if (pre != j) n -= s;
    if (n < 0) return false;
    pre = j;
  }
  return true;
}

ll rst;
ll g(ll x) {
  rst = 0;
  ll res = 0;
  ll pre = -1;
  for (ll i = x/a; i >= 0; --i) {
    ll j = (x-a*i)/b;
    ll s = con(i+j,j);
    ll t = pre!=j?2:1;
    rst += s*t;
    res += s*(a*i+b*j)*t+b;
    if (pre != j) res += a;
    pre = j;
  }
  return res;
}

int main() {
  c[0][0] = 1;
  rep(i,M) {
    rep(j,i+1) c[i+1][j] += c[i][j], c[i+1][j+1] += c[i][j];
    rep(j,i+2) mins(c[i+1][j], INF);
  }
  int n;
  cin >> n >> a >> b;
  if (a > b) swap(a,b);
  if (!a) {
    cout<<b*(n-1)<<endl;
    return 0;
  }
  ll l = 0, r = a*n+1;
  while (l+1<r) {
    ll md = (l+r)>>1;
    if (f(md,n)) l = md; else r = md;
  }
  ll ans = g(l);
  n -= rst;
  ans += n*(r+a+b);
  cout<<ans<<endl;
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

#ifdef ONLINE_JUDGE
#define OJ 1
#else
#define OJ 0
#endif

#define dd				double
#define ll 				int
#define pb 				push_back
#define mp 				make_pair
#define X				first
#define Y				second
#define forn( i, n ) 	for( ll i = 0; i < (ll) (n); i ++ )
#define endl 			'\n'

#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

struct __s { __s() {
		srand( time( NULL ) );
		//freopen( "input.txt", "r", stdin ); freopen( "output.txt", "w", stdout );
		if( OJ ) { ios_base::Init i; cin.sync_with_stdio( 0 ); cin.tie( 0 ); }
	} ~__s() {
		if( !OJ ) TIMESTAMP;
		ll n; cin >> n;
	}
} __S;

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;
priority_queue< pair< long long, pair< ll, ll > > > q;

void add( ll x, ll y ) {
	if( u.find( mp( x, y ) ) != u.end() )
		return;
	u.insert( mp( x, y ) );
	q.push( mp( -( x * c0 + y * c1 ), mp( x, y ) ) );
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 == 0 || c1 == 0 ) {
		long long ans = ( n - 1 ) * max( c1, c0 );
		cout << ans << endl;
		return 0;
	}
	m[mp( 0, 1 )] ++;
	m[mp( 1, 0 )] ++;
	n -= 2;
	add( 0, 1 );
	add( 1, 0 );
	long long ans = c0 + c1;
	while( n ) {
		long long s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		m[mp( p.X + 1, p.Y )] += m[p];
		m[mp( p.X, p.Y + 1 )] += m[p];
		add( p.X + 1, p.Y );
		add( p.X, p.Y + 1 );
		ll k = min( n, m[p] );
		n -= k;
		ans += 1LL * k * ( s + c0 + c1 );
	}
	cout << ans << endl;
	return 0;
}

 #include <bits/stdc++.h>

using namespace std;

#define ll				long long
#define dd				double
#define X				first
#define Y				second
#define mp				make_pair
#define pb				push_back
#define forn( i, n )	for( ll i = 0; i < (ll) (n); i ++ )
#define endl			'\n'

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;

void add( ll x, ll y, priority_queue< pair< ll, pair< ll, ll > > > &q ) {
	if( u.find( mp( x, y ) ) != u.end() )
		return;
	u.insert( mp( x, y ) );
	q.push( mp( -( x * c0 + y * c1 ), mp( x, y ) ) );
}

ll mod = 1e10;

vector< ll > create( ll x ) {
	vector< ll > res;
	if( x == 0 ) {
		res.pb( 0 );
		return res;
	}
	while( x ) {
		res.pb( x % mod );
		x /= mod;
	}
	return res;
}

vector< ll > mul( vector< ll > v, ll x ) {
	vector< ll > res;
	ll ost = 0;
	forn( i, v.size() ) {
		res.pb( v[i] * x );
		res[i] += ost;
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sum( vector< ll > a, vector< ll > b ) {
	vector< ll > res;
	ll n = max( a.size(), b.size() );
	ll ost = 0;
	forn( i, n ) {
		res.pb( ost );
		if( i < a.size() )
			res[i] += a[i];
		if( i < b.size() )
			res[i] += b[i];
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sub( vector< ll > a, vector< ll > b ) {
	vector< ll > res = a;
	forn( i, b.size() ) {
		res[i] -= b[i];
		if( res[i] < 0 ) {
			res[i] += mod;
			if( i + 1 < res.size() )
				res[i + 1] --;
			else
				return mul( create( 1e18 ), 1e8 );
		}
	}
	return res;
}

bool check( vector< ll > a, vector< ll > b ) {
	while( a.size() < b.size() )
		a.pb( 0 );
	while( a.size() > b.size() )
		b.pb( 0 );
	for( ll i = a.size() - 1; i >= 0; i -- ) {
		if( a[i] == b[i] )
			continue;
		if( a[i] > b[i] )
			return true;
		else
			return false;
	}
}

void write( vector< ll > ans ) {
	bool ok = false;
	forn( ii, ans.size() ) {
		ll i = ans.size() - 1 - ii;
		if( !ok && ans[i] == 0 )
			continue;
		ok = true;
		cout << ans[i];
	}
	if( !ok )
		cout << 0;
	cout << endl;
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 > c1 )
		swap( c0, c1 );
	//vector< ll > ans = mul( create( n * ( n - 1 ) / 2 ), c0 );
	vector< ll > ans = sum( create( ( n - 1 ) * c1 ), mul( create( n * ( n - 1 ) / 2 ), c0 ) );
	//ll ans = ( n - 1 ) * c1 + n * ( n - 1 ) / 2 * c0;
	priority_queue< pair< ll, pair< ll, ll > > > q;
	add( 0, 1, q );
	m[mp( 0, 1 )] = 1;
	n --;
	while( n > 0 ) {
		vector< ll > res = ans;
		ll s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		m[mp( p.X + 1, p.Y )] += m[p];
		m[mp( p.X, p.Y + 1 )] += m[p];
		if( p.Y == 1 )
			m[mp( p.X + 1, p.Y )] ++;
		add( p.X + 1, p.Y, q );
		add( p.X, p.Y + 1, q );

		ll k = m[p];
		ll r = n;
		ll l = n - k + 1;
		if( l < 0 ) {
			k += l;
			l = 0;
		}
//l = ( c0 + s ) / c0;
while( c0 + s > l * c0 )
l ++;
if( l > r )
break;
		res = sum( res, create( k * ( c0 + s ) ) );
		//res += k * ( c0 + c1 + s );
		//res -= k * c1;
		res = sub( res, mul( create( ( l + r ) * ( r - l + 1 ) / 2 ), c0 ) );
		//res -= ( l + r ) * ( r - l + 1 ) / 2 * c0;
		n = l - 1;
		ans = res;
		//write( ans );
	}
	write( ans );
	//cout << ans << endl;
	return 0;
}

 #include <bits/stdc++.h>

using namespace std;

#define ll				long long
#define dd				double
#define X				first
#define Y				second
#define mp				make_pair
#define pb				push_back
#define forn( i, n )	for( ll i = 0; i < (ll) (n); i ++ )
#define endl			'\n'

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;

void add( ll x, ll y, priority_queue< pair< ll, pair< ll, ll > > > &q ) {
	if( u.find( mp( x, y ) ) != u.end() )
		return;
	u.insert( mp( x, y ) );
	q.push( mp( -( x * c0 + y * c1 ), mp( x, y ) ) );
}

ll mod = 1e1;

vector< ll > create( ll x ) {
	vector< ll > res;
	if( x == 0 ) {
		res.pb( 0 );
		return res;
	}
	while( x ) {
		res.pb( x % mod );
		x /= mod;
	}
	return res;
}

vector< ll > mul( vector< ll > v, ll x ) {
	vector< ll > res;
	ll ost = 0;
	forn( i, v.size() ) {
		res.pb( v[i] * x );
		res[i] += ost;
		ost = res[i] / mod;
		res[i] %= mod;
	}
	while( ost ) {
		res.pb( ost % mod );
ost /= mod;
}
	return res;
}

vector< ll > sum( vector< ll > a, vector< ll > b ) {
	vector< ll > res;
	ll n = max( a.size(), b.size() );
	ll ost = 0;
	forn( i, n ) {
		res.pb( ost );
		if( i < a.size() )
			res[i] += a[i];
		if( i < b.size() )
			res[i] += b[i];
		ost = res[i] / mod;
		res[i] %= mod;
	}

	while( ost ) {
		res.pb( ost % mod );
ost /= mod;
}
return res;
}

vector< ll > sub( vector< ll > a, vector< ll > b ) {
	vector< ll > res = a;
	forn( i, b.size() ) {
		res[i] -= b[i];
		if( res[i] < 0 ) {
			res[i] += mod;
			if( i + 1 < res.size() )
				res[i + 1] --;
			else
				return mul( create( 1e18 ), 1e8 );
		}
	}
	return res;
}

bool check( vector< ll > a, vector< ll > b ) {
	while( a.size() < b.size() )
		a.pb( 0 );
	while( a.size() > b.size() )
		b.pb( 0 );
	for( ll i = a.size() - 1; i >= 0; i -- ) {
		if( a[i] == b[i] )
			continue;
		if( a[i] > b[i] )
			return true;
		else
			return false;
	}
}

void write( vector< ll > ans ) {
	bool ok = false;
	forn( ii, ans.size() ) {
		ll i = ans.size() - 1 - ii;
		if( !ok && ans[i] == 0 )
			continue;
if( ok ) {
ll m = mod / 10;
while( m ) {
ll x = ans[i] / m;
cout << x;
ans[i] -= x * m;
m /= 10;
}
} else
cout << ans[i];

		ok = true;
	}
	if( !ok )
		cout << 0;
	cout << endl;
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 > c1 )
		swap( c0, c1 );
	//vector< ll > ans = mul( create( n * ( n - 1 ) / 2 ), c0 );
	vector< ll > ans = sum( create( ( n - 1 ) * c1 ), mul( create( n * ( n - 1 ) / 2 ), c0 ) );
	//ll ans = ( n - 1 ) * c1 + n * ( n - 1 ) / 2 * c0;
	priority_queue< pair< ll, pair< ll, ll > > > q;
	add( 0, 1, q );
	m[mp( 0, 1 )] = 1;
	n --;
	while( n > 0 ) {
		vector< ll > res = ans;
		ll s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		m[mp( p.X + 1, p.Y )] += m[p];
		m[mp( p.X, p.Y + 1 )] += m[p];
		if( p.Y == 1 )
			m[mp( p.X + 1, p.Y )] ++;
		add( p.X + 1, p.Y, q );
		add( p.X, p.Y + 1, q );

		ll k = m[p];
		ll r = n;
		ll l = n - k + 1;
		if( l < 0 ) {
			k += l;
			l = 0;
		}
//l = ( c0 + s ) / c0;
while( l <= r && c0 + s > l * c0 ) {
l ++;
k --;
}
if( l > r )
break;
		res = sum( res, create( k * ( c0 + s ) ) );
		//res += k * ( c0 + c1 + s );
		//res -= k * c1;
		res = sub( res, mul( create( ( l + r ) * ( r - l + 1 ) / 2 ), c0 ) );
		//res -= ( l + r ) * ( r - l + 1 ) / 2 * c0;
		n = l - 1;
if( check( res, ans ) )
break;
		ans = res;
		//write( ans );
	}
	write( ans );
	//cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define ll				long long
#define dd				double
#define X				first
#define Y				second
#define mp				make_pair
#define pb				push_back
#define forn( i, n )	for( ll i = 0; i < (ll) (n); i ++ )
#define endl			'\n'

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;

void add( ll x, ll y, priority_queue< pair< ll, pair< ll, ll > > > &q ) {
	if( u.find( mp( x, y ) ) != u.end() )
		return;
	u.insert( mp( x, y ) );
	q.push( mp( -( x * c0 + y * c1 ), mp( x, y ) ) );
}

ll mod = 1e10;

vector< ll > create( ll x ) {
	vector< ll > res;
	if( x == 0 ) {
		res.pb( 0 );
		return res;
	}
	while( x ) {
		res.pb( x % mod );
		x /= mod;
	}
	return res;
}

vector< ll > mul( vector< ll > v, ll x ) {
	vector< ll > res;
	ll ost = 0;
	forn( i, v.size() ) {
		res.pb( v[i] * x );
		res[i] += ost;
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sum( vector< ll > a, vector< ll > b ) {
	vector< ll > res;
	ll n = max( a.size(), b.size() );
	ll ost = 0;
	forn( i, n ) {
		res.pb( ost );
		if( i < a.size() )
			res[i] += a[i];
		if( i < b.size() )
			res[i] += b[i];
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sub( vector< ll > a, vector< ll > b ) {
	vector< ll > res = a;
	forn( i, b.size() ) {
		res[i] -= b[i];
		if( res[i] < 0 ) {
			res[i] += mod;
			if( i + 1 < res.size() )
				res[i + 1] --;
			else
				return mul( create( 1e18 ), 1e8 );
		}
	}
	return res;
}

bool check( vector< ll > a, vector< ll > b ) {
	while( a.size() < b.size() )
		a.pb( 0 );
	while( a.size() > b.size() )
		b.pb( 0 );
	for( ll i = a.size() - 1; i >= 0; i -- ) {
		if( a[i] == b[i] )
			continue;
		if( a[i] > b[i] )
			return true;
		else
			return false;
	}
}

void write( vector< ll > ans ) {
	bool ok = false;
	forn( ii, ans.size() ) {
		ll i = ans.size() - 1 - ii;
		if( !ok && ans[i] == 0 )
			continue;
		ok = true;
		cout << ans[i];
	}
	if( !ok )
		cout << 0;
	cout << endl;
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 > c1 )
		swap( c0, c1 );
	//vector< ll > ans = mul( create( n * ( n - 1 ) / 2 ), c0 );
	vector< ll > ans = sum( create( ( n - 1 ) * c1 ), mul( create( n * ( n - 1 ) / 2 ), c0 ) );
	//ll ans = ( n - 1 ) * c1 + n * ( n - 1 ) / 2 * c0;
	priority_queue< pair< ll, pair< ll, ll > > > q;
	add( 0, 1, q );
	m[mp( 0, 1 )] = 1;
	n --;
	while( n > 0 ) {
		vector< ll > res = ans;
		ll s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		m[mp( p.X + 1, p.Y )] += m[p];
		m[mp( p.X, p.Y + 1 )] += m[p];
		if( p.Y == 1 )
			m[mp( p.X + 1, p.Y )] ++;
		add( p.X + 1, p.Y, q );
		add( p.X, p.Y + 1, q );

		ll k = m[p];
		ll r = n;
		ll l = n - k + 1;
		if( l < 0 ) {
			k += l;
			l = 0;
		}
		res = sum( res, create( k * ( c0 + c1 + s ) ) );
		//res += k * ( c0 + c1 + s );
		res = sub( res, create( k * c1 ) );
		//res -= k * c1;
		res = sub( res, mul( create( ( l + r ) * ( r - l + 1 ) / 2 ), c0 ) );
		//res -= ( l + r ) * ( r - l + 1 ) / 2 * c0;
		n = l - 1;
		if( check( res, ans ) ) {
			while( c0 + c1 + s < r * c0 + c1 ) {
				ans = sub( ans, create( ( r * c0 + c1 ) - ( c0 + c1 + s ) ) );
				r --;
			}
			break;
		}
		ans = res;
		//write( ans );
	}
	write( ans );
	//cout << ans << endl;
	return 0;
}

 #include <bits/stdc++.h>

using namespace std;

#define ll				long long
#define dd				double
#define X				first
#define Y				second
#define mp				make_pair
#define pb				push_back
#define forn( i, n )	for( ll i = 0; i < (ll) (n); i ++ )
#define endl			'\n'

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;

void add( ll x, ll y, priority_queue< pair< ll, pair< ll, ll > > > &q ) {
	if( u.find( mp( x, y ) ) != u.end() )
		return;
	u.insert( mp( x, y ) );
	q.push( mp( -( x * c0 + y * c1 ), mp( x, y ) ) );
}

ll mod = 1e2;

vector< ll > create( ll x ) {
	vector< ll > res;
	if( x == 0 ) {
		res.pb( 0 );
		return res;
	}
	while( x ) {
		res.pb( x % mod );
		x /= mod;
	}
	return res;
}

vector< ll > mul( vector< ll > v, ll x ) {
	vector< ll > res;
	ll ost = 0;
	forn( i, v.size() ) {
		res.pb( v[i] * x );
		res[i] += ost;
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sum( vector< ll > a, vector< ll > b ) {
	vector< ll > res;
	ll n = max( a.size(), b.size() );
	ll ost = 0;
	forn( i, n ) {
		res.pb( ost );
		if( i < a.size() )
			res[i] += a[i];
		if( i < b.size() )
			res[i] += b[i];
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sub( vector< ll > a, vector< ll > b ) {
	vector< ll > res = a;
	forn( i, b.size() ) {
		res[i] -= b[i];
		if( res[i] < 0 ) {
			res[i] += mod;
			if( i + 1 < res.size() )
				res[i + 1] --;
			else
				return mul( create( 1e18 ), 1e8 );
		}
	}
	return res;
}

bool check( vector< ll > a, vector< ll > b ) {
	while( a.size() < b.size() )
		a.pb( 0 );
	while( a.size() > b.size() )
		b.pb( 0 );
	for( ll i = a.size() - 1; i >= 0; i -- ) {
		if( a[i] == b[i] )
			continue;
		if( a[i] > b[i] )
			return true;
		else
			return false;
	}
}

void write( vector< ll > ans ) {
	bool ok = false;
	forn( ii, ans.size() ) {
		ll i = ans.size() - 1 - ii;
		if( !ok && ans[i] == 0 )
			continue;
if( ok ) {
ll m = mod / 10;
while( m ) {
ll x = ans[i] / m;
cout << x;
ans[i] -= x * m;
m /= 10;
}
} else
cout << ans[i];

		ok = true;
	}
	if( !ok )
		cout << 0;
	cout << endl;
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 > c1 )
		swap( c0, c1 );
	//vector< ll > ans = mul( create( n * ( n - 1 ) / 2 ), c0 );
	vector< ll > ans = sum( create( ( n - 1 ) * c1 ), mul( create( n * ( n - 1 ) / 2 ), c0 ) );
	//ll ans = ( n - 1 ) * c1 + n * ( n - 1 ) / 2 * c0;
	priority_queue< pair< ll, pair< ll, ll > > > q;
	add( 0, 1, q );
	m[mp( 0, 1 )] = 1;
	n --;
	while( n > 0 ) {
		vector< ll > res = ans;
		ll s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		m[mp( p.X + 1, p.Y )] += m[p];
		m[mp( p.X, p.Y + 1 )] += m[p];
		if( p.Y == 1 )
			m[mp( p.X + 1, p.Y )] ++;
		add( p.X + 1, p.Y, q );
		add( p.X, p.Y + 1, q );

		ll k = m[p];
		ll r = n;
		ll l = n - k + 1;
		if( l < 0 ) {
			k += l;
			l = 0;
		}
//l = ( c0 + s ) / c0;
while( l <= r && c0 + s > l * c0 ) {
l ++;
k --;
}
if( l > r )
break;
		res = sum( res, create( k * ( c0 + s ) ) );
		//res += k * ( c0 + c1 + s );
		//res -= k * c1;
		res = sub( res, mul( create( ( l + r ) * ( r - l + 1 ) / 2 ), c0 ) );
		//res -= ( l + r ) * ( r - l + 1 ) / 2 * c0;
		n = l - 1;
if( check( res, ans ) )
break;
		ans = res;
		//write( ans );
	}
	write( ans );
	//cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define ll				long long
#define dd				double
#define X				first
#define Y				second
#define mp				make_pair
#define pb				push_back
#define forn( i, n )	for( ll i = 0; i < (ll) (n); i ++ )
#define endl			'\n'

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;

void add( ll x, ll y, priority_queue< pair< ll, pair< ll, ll > > > &q ) {
	if( u.find( mp( x, y ) ) != u.end() )
		return;
	u.insert( mp( x, y ) );
	q.push( mp( -( x * c0 + y * c1 ), mp( x, y ) ) );
}

ll mod = 1e10;

vector< ll > create( ll x ) {
	vector< ll > res;
	if( x == 0 ) {
		res.pb( 0 );
		return res;
	}
	while( x ) {
		res.pb( x % mod );
		x /= mod;
	}
	return res;
}

vector< ll > mul( vector< ll > v, ll x ) {
	vector< ll > res;
	ll ost = 0;
	forn( i, v.size() ) {
		res.pb( v[i] * x );
		res[i] += ost;
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sum( vector< ll > a, vector< ll > b ) {
	vector< ll > res;
	ll n = max( a.size(), b.size() );
	ll ost = 0;
	forn( i, n ) {
		res.pb( ost );
		if( i < a.size() )
			res[i] += a[i];
		if( i < b.size() )
			res[i] += b[i];
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sub( vector< ll > a, vector< ll > b ) {
	vector< ll > res = a;
	forn( i, b.size() ) {
		res[i] -= b[i];
		if( res[i] < 0 ) {
			res[i] += mod;
			if( i + 1 < res.size() )
				res[i + 1] --;
			else
				return mul( create( 1e18 ), 1e8 );
		}
	}
	return res;
}

bool check( vector< ll > a, vector< ll > b ) {
	while( a.size() < b.size() )
		a.pb( 0 );
	while( a.size() > b.size() )
		b.pb( 0 );
	for( ll i = a.size() - 1; i >= 0; i -- ) {
		if( a[i] == b[i] )
			continue;
		if( a[i] > b[i] )
			return true;
		else
			return false;
	}
}

void write( vector< ll > ans ) {
	bool ok = false;
	forn( ii, ans.size() ) {
		ll i = ans.size() - 1 - ii;
		if( !ok && ans[i] == 0 )
			continue;
		ok = true;
		cout << ans[i];
	}
	if( !ok )
		cout << 0;
	cout << endl;
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 > c1 )
		swap( c0, c1 );
	//vector< ll > ans = mul( create( n * ( n - 1 ) / 2 ), c0 );
	vector< ll > ans = sum( create( ( n - 1 ) * c1 ), mul( create( n * ( n - 1 ) / 2 ), c0 ) );
	//ll ans = ( n - 1 ) * c1 + n * ( n - 1 ) / 2 * c0;
	priority_queue< pair< ll, pair< ll, ll > > > q;
	add( 0, 1, q );
	m[mp( 0, 1 )] = 1;
	n --;
	while( n > 0 ) {
		vector< ll > res = ans;
		ll s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		m[mp( p.X + 1, p.Y )] += m[p];
		m[mp( p.X, p.Y + 1 )] += m[p];
		if( p.Y == 1 )
			m[mp( p.X + 1, p.Y )] ++;
		add( p.X + 1, p.Y, q );
		add( p.X, p.Y + 1, q );

		ll k = m[p];
		ll r = n;
		ll l = n - k + 1;
		if( l < 0 ) {
			k += l;
			l = 0;
		}
		res = sum( res, create( k * ( c0 + s ) ) );
		//res += k * ( c0 + c1 + s );
		//res -= k * c1;
		res = sub( res, mul( create( ( l + r ) * ( r - l + 1 ) / 2 ), c0 ) );
		//res -= ( l + r ) * ( r - l + 1 ) / 2 * c0;
		n = l - 1;
		if( check( res, ans ) ) {
			while( c0 + s < r * c0 ) {
				ans = sub( ans, create( ( r * c0 ) - ( c0 + s ) ) );
				r --;
			}
			break;
		}
		ans = res;
		//write( ans );
	}
	write( ans );
	//cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define ll				long long
#define dd				double
#define X				first
#define Y				second
#define mp				make_pair
#define pb				push_back
#define forn( i, n )	for( ll i = 0; i < (ll) (n); i ++ )
#define endl			'\n'

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;

void add( ll x, ll y, priority_queue< pair< ll, pair< ll, ll > > > &q ) {
	if( u.find( mp( x, y ) ) != u.end() )
		return;
	u.insert( mp( x, y ) );
	q.push( mp( -( x * c0 + y * c1 ), mp( x, y ) ) );
}

ll mod = 1e10;

vector< ll > create( ll x ) {
	vector< ll > res;
	if( x == 0 ) {
		res.pb( 0 );
		return res;
	}
	while( x ) {
		res.pb( x % mod );
		x /= mod;
	}
	return res;
}

vector< ll > mul( vector< ll > v, ll x ) {
	vector< ll > res;
	ll ost = 0;
	forn( i, v.size() ) {
		res.pb( v[i] * x );
		res[i] += ost;
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sum( vector< ll > a, vector< ll > b ) {
	vector< ll > res;
	ll n = max( a.size(), b.size() );
	ll ost = 0;
	forn( i, n ) {
		res.pb( ost );
		if( i < a.size() )
			res[i] += a[i];
		if( i < b.size() )
			res[i] += b[i];
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sub( vector< ll > a, vector< ll > b ) {
	vector< ll > res = a;
	forn( i, b.size() ) {
		res[i] -= b[i];
		if( res[i] < 0 ) {
			res[i] += mod;
			if( i + 1 < res.size() )
				res[i + 1] --;
			else
				return mul( create( 1e18 ), 1e8 );
		}
	}
	return res;
}

bool check( vector< ll > a, vector< ll > b ) {
	while( a.size() < b.size() )
		a.pb( 0 );
	while( a.size() > b.size() )
		b.pb( 0 );
	for( ll i = a.size() - 1; i >= 0; i -- ) {
		if( a[i] == b[i] )
			continue;
		if( a[i] > b[i] )
			return true;
		else
			return false;
	}
}

void write( vector< ll > ans ) {
	bool ok = false;
	forn( ii, ans.size() ) {
		ll i = ans.size() - 1 - ii;
		if( !ok && ans[i] == 0 )
			continue;
		ok = true;
		cout << ans[i];
	}
	if( !ok )
		cout << 0;
	cout << endl;
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 > c1 )
		swap( c0, c1 );
	//vector< ll > ans = mul( create( n * ( n - 1 ) / 2 ), c0 );
	vector< ll > ans = sum( create( ( n - 1 ) * c1 ), mul( create( n * ( n - 1 ) / 2 ), c0 ) );
	//ll ans = ( n - 1 ) * c1 + n * ( n - 1 ) / 2 * c0;
	priority_queue< pair< ll, pair< ll, ll > > > q;
	add( 0, 1, q );
	m[mp( 0, 1 )] = 1;
	n --;
	while( n > 0 ) {
		vector< ll > res = ans;
		ll s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		m[mp( p.X + 1, p.Y )] += m[p];
		m[mp( p.X, p.Y + 1 )] += m[p];
		if( p.Y == 1 )
			m[mp( p.X + 1, p.Y )] ++;
		add( p.X + 1, p.Y, q );
		add( p.X, p.Y + 1, q );

		ll k = m[p];
		ll r = n;
		ll l = n - k + 1;
		if( l < 0 ) {
			k += l;
			l = 0;
		}
		res = sum( res, create( k * ( c0 + c1 + s ) ) );
		//res += k * ( c0 + c1 + s );
		res = sub( res, create( k * c1 ) );
		//res -= k * c1;
		res = sub( res, mul( create( ( l + r ) * ( r - l + 1 ) / 2 ), c0 ) );
		//res -= ( l + r ) * ( r - l + 1 ) / 2 * c0;
		n = l - 1;
		if( check( res, ans ) )
			break;
		ans = res;
	}
	write( ans );
	//cout << ans << endl;
	return 0;
}

 #include <bits/stdc++.h>

using namespace std;

#define ll				long long
#define dd				double
#define X				first
#define Y				second
#define mp				make_pair
#define pb				push_back
#define forn( i, n )	for( ll i = 0; i < (ll) (n); i ++ )
#define endl			'\n'

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;

void add( ll x, ll y, priority_queue< pair< ll, pair< ll, ll > > > &q ) {
	if( u.find( mp( x, y ) ) != u.end() )
		return;
	u.insert( mp( x, y ) );
	q.push( mp( -( x * c0 + y * c1 ), mp( x, y ) ) );
}

ll mod = 1e10;

vector< ll > create( ll x ) {
	vector< ll > res;
	if( x == 0 ) {
		res.pb( 0 );
		return res;
	}
	while( x ) {
		res.pb( x % mod );
		x /= mod;
	}
	return res;
}

vector< ll > mul( vector< ll > v, ll x ) {
	vector< ll > res;
	ll ost = 0;
	forn( i, v.size() ) {
		res.pb( v[i] * x );
		res[i] += ost;
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sum( vector< ll > a, vector< ll > b ) {
	vector< ll > res;
	ll n = max( a.size(), b.size() );
	ll ost = 0;
	forn( i, n ) {
		res.pb( ost );
		if( i < a.size() )
			res[i] += a[i];
		if( i < b.size() )
			res[i] += b[i];
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sub( vector< ll > a, vector< ll > b ) {
	vector< ll > res = a;
	forn( i, b.size() ) {
		res[i] -= b[i];
		if( res[i] < 0 ) {
			res[i] += mod;
			if( i + 1 < res.size() )
				res[i + 1] --;
			else
				return mul( create( 1e18 ), 1e8 );
		}
	}
	return res;
}

bool check( vector< ll > a, vector< ll > b ) {
	while( a.size() < b.size() )
		a.pb( 0 );
	while( a.size() > b.size() )
		b.pb( 0 );
	for( ll i = a.size() - 1; i >= 0; i -- ) {
		if( a[i] == b[i] )
			continue;
		if( a[i] > b[i] )
			return true;
		else
			return false;
	}
}

void write( vector< ll > ans ) {
	bool ok = false;
	forn( ii, ans.size() ) {
		ll i = ans.size() - 1 - ii;
		if( !ok && ans[i] == 0 )
			continue;
		ok = true;
		cout << ans[i];
	}
	if( !ok )
		cout << 0;
	cout << endl;
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 > c1 )
		swap( c0, c1 );
	//vector< ll > ans = mul( create( n * ( n - 1 ) / 2 ), c0 );
	vector< ll > ans = sum( create( ( n - 1 ) * c1 ), mul( create( n * ( n - 1 ) / 2 ), c0 ) );
	//ll ans = ( n - 1 ) * c1 + n * ( n - 1 ) / 2 * c0;
	priority_queue< pair< ll, pair< ll, ll > > > q;
	add( 0, 1, q );
	m[mp( 0, 1 )] = 1;
	n --;
	while( n > 0 ) {
		vector< ll > res = ans;
		ll s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		m[mp( p.X + 1, p.Y )] += m[p];
		m[mp( p.X, p.Y + 1 )] += m[p];
		if( p.Y == 1 )
			m[mp( p.X + 1, p.Y )] ++;
		add( p.X + 1, p.Y, q );
		add( p.X, p.Y + 1, q );

		ll k = m[p];
		ll r = n;
		ll l = n - k + 1;
		if( l < 0 ) {
			k += l;
			l = 0;
		}
//l = ( c0 + s ) / c0;
while( l <= r && c0 + s > l * c0 ) {
l ++;
k --;
}
if( l > r )
break;
		res = sum( res, create( k * ( c0 + s ) ) );
		//res += k * ( c0 + c1 + s );
		//res -= k * c1;
		res = sub( res, mul( create( ( l + r ) * ( r - l + 1 ) / 2 ), c0 ) );
		//res -= ( l + r ) * ( r - l + 1 ) / 2 * c0;
		n = l - 1;
if( check( res, ans ) )
break;
		ans = res;
		//write( ans );
	}
	write( ans );
	//cout << ans << endl;
	return 0;
}

 #include <bits/stdc++.h>

using namespace std;

#define ll				long long
#define dd				double
#define X				first
#define Y				second
#define mp				make_pair
#define pb				push_back
#define forn( i, n )	for( ll i = 0; i < (ll) (n); i ++ )
#define endl			'\n'

ll n, c0, c1;
map< pair< ll, ll >, ll > m;
set< pair< ll, ll > > u;

void add( ll x, ll y, priority_queue< pair< ll, pair< ll, ll > > > &q ) {
	if( u.find( mp( x, y ) ) != u.end() )
		return;
	u.insert( mp( x, y ) );
	q.push( mp( -( x * c0 + y * c1 ), mp( x, y ) ) );
}

ll mod = 1e1;

vector< ll > create( ll x ) {
	vector< ll > res;
	if( x == 0 ) {
		res.pb( 0 );
		return res;
	}
	while( x ) {
		res.pb( x % mod );
		x /= mod;
	}
	return res;
}

vector< ll > mul( vector< ll > v, ll x ) {
	vector< ll > res;
	ll ost = 0;
	forn( i, v.size() ) {
		res.pb( v[i] * x );
		res[i] += ost;
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sum( vector< ll > a, vector< ll > b ) {
	vector< ll > res;
	ll n = max( a.size(), b.size() );
	ll ost = 0;
	forn( i, n ) {
		res.pb( ost );
		if( i < a.size() )
			res[i] += a[i];
		if( i < b.size() )
			res[i] += b[i];
		ost = res[i] / mod;
		res[i] %= mod;
	}
	if( ost )
		res.pb( ost );
	return res;
}

vector< ll > sub( vector< ll > a, vector< ll > b ) {
	vector< ll > res = a;
	forn( i, b.size() ) {
		res[i] -= b[i];
		if( res[i] < 0 ) {
			res[i] += mod;
			if( i + 1 < res.size() )
				res[i + 1] --;
			else
				return mul( create( 1e18 ), 1e8 );
		}
	}
	return res;
}

bool check( vector< ll > a, vector< ll > b ) {
	while( a.size() < b.size() )
		a.pb( 0 );
	while( a.size() > b.size() )
		b.pb( 0 );
	for( ll i = a.size() - 1; i >= 0; i -- ) {
		if( a[i] == b[i] )
			continue;
		if( a[i] > b[i] )
			return true;
		else
			return false;
	}
}

void write( vector< ll > ans ) {
	bool ok = false;
	forn( ii, ans.size() ) {
		ll i = ans.size() - 1 - ii;
		if( !ok && ans[i] == 0 )
			continue;
if( ok ) {
ll m = mod / 10;
while( m ) {
ll x = ans[i] / m;
cout << x;
ans[i] -= x * m;
m /= 10;
}
} else
cout << ans[i];

		ok = true;
	}
	if( !ok )
		cout << 0;
	cout << endl;
}

int main( void ) {
	cin >> n >> c0 >> c1;
	if( c0 > c1 )
		swap( c0, c1 );
	//vector< ll > ans = mul( create( n * ( n - 1 ) / 2 ), c0 );
	vector< ll > ans = sum( create( ( n - 1 ) * c1 ), mul( create( n * ( n - 1 ) / 2 ), c0 ) );
	//ll ans = ( n - 1 ) * c1 + n * ( n - 1 ) / 2 * c0;
	priority_queue< pair< ll, pair< ll, ll > > > q;
	add( 0, 1, q );
	m[mp( 0, 1 )] = 1;
	n --;
	while( n > 0 ) {
		vector< ll > res = ans;
		ll s = -q.top().X;
		pair< ll, ll > p = q.top().Y;
		q.pop();
		m[mp( p.X + 1, p.Y )] += m[p];
		m[mp( p.X, p.Y + 1 )] += m[p];
		if( p.Y == 1 )
			m[mp( p.X + 1, p.Y )] ++;
		add( p.X + 1, p.Y, q );
		add( p.X, p.Y + 1, q );

		ll k = m[p];
		ll r = n;
		ll l = n - k + 1;
		if( l < 0 ) {
			k += l;
			l = 0;
		}
//l = ( c0 + s ) / c0;
while( l <= r && c0 + s > l * c0 ) {
l ++;
k --;
}
if( l > r )
break;
		res = sum( res, create( k * ( c0 + s ) ) );
		//res += k * ( c0 + c1 + s );
		//res -= k * c1;
		res = sub( res, mul( create( ( l + r ) * ( r - l + 1 ) / 2 ), c0 ) );
		//res -= ( l + r ) * ( r - l + 1 ) / 2 * c0;
		n = l - 1;
if( check( res, ans ) )
break;
		ans = res;
		//write( ans );
	}
	write( ans );
	//cout << ans << endl;
	return 0;
}

#include<cstdio>
#include<cmath>
#define ll long long
int n,a,b;ll l,r,ans;
int check(ll m){
	int sum=-1;
	for (int i=0;(ll)i*b<=m&&sum<n;i++)
		sum+=(m-i*b)/a+1;
	return sum>=n;
}
void slove(ll m){
	int sum=-1;
	for (int i=0;(ll)i*b<=m;i++){
		int k=(m-i*b)/a+1;sum+=k;
		ans+=(ll)k*i*b+(ll)k*(k-1)/2*a;
	}
	ans-=m*(sum-n);
}
int main(){
	scanf("%d%d%d",&n,&a,&b);
	if (a>b) a^=b,b^=a,a^=b;
	n--;ans+=(ll)n*(a+b);n--;
	if (!a){printf("%I64d",ans);return 0;}
	for (r=n*a;l<r;){ll m=l+r>>1;
		if (check(m)) r=m; else l=m+1;
	}
	slove(l);
	printf("%I64d",ans);
}

#include<cstdio>
#include<cmath>
#define ll long long
const int S=2e4;
int n,m,s,a,b,c[S];ll l,r,ans;
bool check(ll m){
	int sum=-1,i,j;
	for (i=0;i<=s;i++) c[i]=1;
	for (i=0;(ll)i*b<=m&&sum<n;i++)
		for (j=0;(ll)i*b+(ll)j*a<=m;j++){
			sum+=c[j];if (j) c[j]+=c[j-1];
		}
	return sum>=n;
}
void slove(ll m){
	int sum=-1,i,j;
	for (i=0;i<=s;i++) c[i]=1;
	for (i=0;(ll)i*b<=m;i++)
		for (j=0;(ll)i*b+(ll)j*a<=m;j++){
			sum+=c[j];ans+=c[j]*((ll)i*b+(ll)j*a);
			if (j) c[j]+=c[j-1];
		}
	ans-=m*(sum-n);
}
int main(){
	scanf("%d%d%d",&n,&a,&b);
	if (a>b) a^=b,b^=a,a^=b;
	n--;ans+=(ll)n*(a+b);
	n--;s=sqrt(n*2)+1;
	if (!a){printf("%I64d",ans);return 0;}
	for (r=b+(ll)s*a;l<r;){ll m=l+r>>1;
		if (check(m)) r=m; else l=m+1;
	}
	slove(l);
	printf("%I64d",ans);
}

#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,c0,c1,C[70][50010];
const int N=60,M=40000;
struct atom{
	long long w;
	int num;
}A[50];
int len;
int check(long long lim){
	int now=min(1ll*n,lim/c1);
	for (int i=1;i<=N;i++){
		int j=0;
		while (1ll*i*c0+1ll*j*c1<=lim&&now<n){
			now=min(n,now+C[i][j]); j++;
		}
	}
	return now;
}
int compare(atom k1,atom k2){
	return k1.w<k2.w;
}
long long calc(long long lim){
//	cout<<"asd "<<lim<<endl;
	long long ans=1ll*n*(c0+c1); int len=0;
	int k=lim/c1; A[++len]=(atom){1ll*k*c1,1};
	int rem=n;
	k--; if (k>=0) ans+=1ll*(k+1)*k/2*c1,rem-=k+1;
	for (int i=1;i<=N;i++){
		int j=0;
		while (1ll*i*c0+1ll*j*c1<=lim) j++;
		j--; if (j<0) continue;
		A[++len]=(atom){1ll*i*c0+1ll*j*c1,C[i][j]};
		while (j>=0){
			ans+=(1ll*i*c0+1ll*j*c1)*C[i][j]; rem-=C[i][j]; j--;
		}
	}
	sort(A+1,A+len+1,compare);
	for (int i=1;i<=len;i++){
		int k=min(rem,A[i].num);
		ans+=1ll*k*A[i].w; rem-=k;
	}
	return ans;
}
int main(){
	scanf("%d%d%d",&n,&c0,&c1);
	if (c0<c1) swap(c0,c1); n--;
	if (n==0){
		cout<<0<<endl; return 0;
	}
	if (c1==0){
		cout<<1ll*n*c0<<endl; return 0;
	}
	for (int i=0;i<=M;i++) C[0][i]=1;
	for (int i=1;i<=N;i++){
		C[i][0]=1;
		for (int j=1;j<=M;j++) C[i][j]=min(C[i-1][j]+C[i][j-1],n);
	}
	long long l=0,r=1e17,ans=0;
	while (l<r){
		long long mid=l+r>>1;
		if (check(mid)>=n){
			ans=mid; r=mid;
		} else l=mid+1;
	}
//	cout<<ans<<endl;
	cout<<calc(ans)<<endl;
	return 0;
}

#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,c0,c1,C[50][10010];
const int N=40,M=10000;
struct atom{
	long long w;
	int num;
}A[50];
int len;
int check(long long lim){
	int now=min(1ll*n,lim/c1);
	for (int i=1;i<=N;i++){
		int j=0;
		while (1ll*i*c0+1ll*j*c1<=lim&&now<n){
			now=min(n,now+C[i][j]); j++;
		}
	}
	return now;
}
int compare(atom k1,atom k2){
	return k1.w<k2.w;
}
long long calc(long long lim){
//	cout<<"asd "<<lim<<endl;
	long long ans=1ll*n*(c0+c1); int len=0;
	int k=lim/c0; A[++len]=(atom){1ll*k*c1,1};
	int rem=n;
	k--; if (k>=0) ans+=1ll*(k+1)*k/2*c1,rem-=k+1;
	for (int i=1;i<=N;i++){
		int j=0;
		while (1ll*i*c0+1ll*j*c1<=lim) j++;
		j--; if (j<0) continue;
		A[++len]=(atom){1ll*i*c0+1ll*j*c1,C[i][j]};
		while (j>=0){
			ans+=(1ll*i*c0+1ll*j*c1)*C[i][j]; rem-=C[i][j]; j--;
		}
	}
	sort(A+1,A+len+1,compare);
	for (int i=1;i<=len;i++){
		int k=min(rem,A[i].num);
		ans+=1ll*k*A[i].w; rem-=k;
	}
	return ans;
}
int main(){
	scanf("%d%d%d",&n,&c0,&c1);
	if (c0<c1) swap(c0,c1); n--;
	if (n==0){
		cout<<0<<endl; return 0;
	}
	if (c1==0){
		cout<<1ll*n*c0<<endl; return 0;
	}
	for (int i=0;i<=M;i++) C[0][i]=1;
	for (int i=1;i<=N;i++){
		C[i][0]=1;
		for (int j=1;j<=M;j++) C[i][j]=min(C[i-1][j]+C[i][j-1],n);
	}
	long long l=0,r=1e17,ans=0;
	while (l<r){
		long long mid=l+r>>1;
		if (check(mid)>=n){
			ans=mid; r=mid;
		} else l=mid+1;
	}
	cout<<calc(ans)<<endl;
	return 0;
}

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#define clr(x) memset((x), 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define sz size()
#define For(i, st, en) for(int i=(st); i<=(int)(en); i++)
#define Ford(i, st, en) for(int i=(st); i>=(int)(en); i--)
#define forn(i, n) for(int i=0; i<(int)(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

#ifdef ROOM_311
__attribute__((destructor)) void fini_main()
{
	fprintf(stderr, "Execution time = %0.0lf ms\n", clock() * 1000.0 / CLOCKS_PER_SEC);
}
#endif

#define MY_RAND 1
#if MY_RAND
uint64_t rnd_data = 0xDEADBEEFDULL;
inline void my_srand(int seed) { rnd_data = ((uint64_t)seed << 16) | 0x330E; }
inline int my_rand() { rnd_data = rnd_data * 0x5DEECE66DULL + 0xB; return (rnd_data >> 17) & 0x7FFFFFFF; }
#define rand my_rand
#define srand my_srand
#endif

template <class _T> inline _T sqr(const _T &x) { return x * x; }
template <class _T> inline string tostr(const _T &a) { ostringstream os(""); os << a; return os.str(); }

// Types
typedef long double ld;
typedef long long i64;
typedef unsigned long long u64;
typedef pair < int, int > PII;
typedef set < int > SI;
typedef vector < int > VI;
typedef map < string, int > MSI;

// Constants
const ld PI = 3.1415926535897932384626433832795L;
const ld EPS = 1e-11;

const int MAXQ = 10240000;

int n, c0, c1;
int q[MAXQ];

void solve2()
{
	int cc = c0 + c1;
	i64 ans = 0;
	clr(q);
	int k = 0;
	for (n--; n; k++)
	{
		while (k < c1 && k % c0) ++k;
		int add;
		if (k < c1)
		{
			add = 1;
		}
		else
		{
			while (!q[k - c1]) ++k;
			add = min(n, q[k - c1]);
		}
		ans += (k + cc) * (i64)add;
		int k1 = k + c0;
		int k2 = k + c1;
		if (k1 >= c1 && k1 - c1 < MAXQ) q[k1 - c1] += add;
		if (k2 >= c1 && k2 - c1 < MAXQ) q[k2 - c1] += add;
		n -= add;
	}
	printf("%lld\n", ans);
}

int main()
{
#ifdef ROOM_311
	freopen("input.txt", "rt", stdin);
#endif
	cout << setiosflags(ios::fixed) << setprecision(10);

	scanf("%d%d%d", &n, &c0, &c1);
	if (c0 > c1) swap(c0, c1);
	if (!c0)
	{
		printf("%lld\n", c1 * (i64)(n - 1));
		return 0;
	}
	if (1 || c1 / c0 > 1000000)
	{
		solve2();
		return 0;
	}
	map < i64, i64 > q;
	int cc = c0 + c1;
	n--;
	q[0] = 1;
	i64 ans = 0;
	i64 last = 0;
	while (n)
	{
		__typeof(q.begin()) it = q.begin();
		i64 k = it->first;
		int add = min((i64)n, it->second);
		q.erase(it);
		last = k;
		ans += (k + cc) * (i64)add;
		i64 k1 = k + c0;
		i64 k2 = k + c1;
		q[k1] += add;
		q[k2] += add;
		n -= add;
	}
	fprintf(stderr, "last = %lld\n", last);
	printf("%lld\n", ans);

	return 0;
}

#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...)
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)

#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 1000010

template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}

//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

int main(){
    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);
    int i,j,k=0,ca=0,T,K,n,m=0;
    int c0,c1;
    scanf("%d%d%d",&n,&c0,&c1);
    map<ll,int>g;
    g[0]=1;
    ll ans=0,cc=c0+c1;
    while(n){
        ll a=g.begin()->x;int b=g.begin()->y;g.erase(g.begin());
        int c=min(n,b);
        ans+=c*cc;
        g[a+c0]+=c;g[a+c1]+=c;
        n-=c;
    }
    printf("%I64d\n",ans);
    //cerr<<1.*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}

#include<cstdio>
#include<algorithm>
using namespace std;
const int T=1e6,M=1e5;
int he1,ta1,he2,ta2;
long long ans,q1[1000010],q2[1000010];
int n,x,y;
int main()
{
	scanf("%d%d%d",&n,&x,&y);
	n-=2;
	q1[ta1++]=x;
	q2[ta2++]=y;
	ans=x+y;
	while (n--)
	{
	//	if (n%M==0) printf("%d %d %d %d\n",he1,ta1,he2,ta2);
		if (ta1>T)
		{
			if (ta1-he1<M) ta1-=T; else ta1--;
		}
		if (ta2>T)
		{
			if (ta2-he2<M) ta2-=T; else ta2--;
		}
		if (q1[he1]<q2[he2])
		{
			q1[ta1++]=q1[he1]+x;
			q2[ta2++]=q1[he1]+y;
			ans=ans+q1[he1]+x+y;
			he1++;
			if (he1>T&&he1>ta1) he1-=T;
		} else
		{
			q1[ta1++]=q2[he2]+x;
			q2[ta2++]=q2[he2]+y;
			ans=ans+q2[he2]+x+y;
			he2++;
			if (he2>T&&he2>ta2) he2-=T;
		}
	}
	printf("%lld\n",ans);
}

/*
ID: bqi3431
PROG: newlang
LANG: C++11
*/

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 200005;
const ld PI = 4*atan((ld)1);

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

namespace input {
    template<class T> void re(complex<T>& x);
    template<class T1, class T2> void re(pair<T1,T2>& p);
    template<class T> void re(vector<T>& a);
    template<class T, size_t SZ> void re(array<T,SZ>& a);

    template<class T> void re(T& x) { cin >> x; }
    void re(double& x) { string t; re(t); x = stod(t); }
    void re(ld& x) { string t; re(t); x = stold(t); }
    template<class Arg, class... Args> void re(Arg& first, Args&... rest) {
        re(first); re(rest...);
    }

    template<class T> void re(complex<T>& x) { T a,b; re(a,b); x = cd(a,b); }
    template<class T1, class T2> void re(pair<T1,T2>& p) { re(p.f,p.s); }
    template<class T> void re(vector<T>& a) { F0R(i,sz(a)) re(a[i]); }
    template<class T, size_t SZ> void re(array<T,SZ>& a) { F0R(i,SZ) re(a[i]); }
}

using namespace input;

namespace output {
    template<class T1, class T2> void pr(const pair<T1,T2>& x);
    template<class T, size_t SZ> void pr(const array<T,SZ>& x);
    template<class T> void pr(const vector<T>& x);
    template<class T> void pr(const set<T>& x);
    template<class T1, class T2> void pr(const map<T1,T2>& x);

    template<class T> void pr(const T& x) { cout << x; }
    template<class Arg, class... Args> void pr(const Arg& first, const Args&... rest) {
        pr(first); pr(rest...);
    }

    template<class T1, class T2> void pr(const pair<T1,T2>& x) {
        pr("{",x.f,", ",x.s,"}");
    }
    template<class T> void prContain(const T& x) {
        pr("{");
        bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; // const needed for vector<bool>
        pr("}");
    }
    template<class T, size_t SZ> void pr(const array<T,SZ>& x) { prContain(x); }
    template<class T> void pr(const vector<T>& x) { prContain(x); }
    template<class T> void pr(const set<T>& x) { prContain(x); }
    template<class T1, class T2> void pr(const map<T1,T2>& x) { prContain(x); }

    void ps() { pr("\n"); }
    template<class Arg> void ps(const Arg& first) {
        pr(first); ps(); // no space at end of line
    }
    template<class Arg, class... Args> void ps(const Arg& first, const Args&... rest) {
        pr(first," "); ps(rest...); // print w/ spaces
    }
}

using namespace output;

namespace io {
    void setIn(string s) { freopen(s.c_str(),"r",stdin); }
    void setOut(string s) { freopen(s.c_str(),"w",stdout); }
    void setIO(string s = "") {
        ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
        if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
    }
}

using namespace io;

template<class T> T invGeneral(T a, T b) {
    a %= b; if (a == 0) return b == 1 ? 0 : -1;
    T x = invGeneral(b,a);
    return x == -1 ? -1 : ((1-(ll)b*x)/a+b)%b;
}

template<class T> struct modular {
    T val;
    explicit operator T() const { return val; }
    modular() { val = 0; }
    template<class U> modular(const U& v) {
        val = (-MOD <= v && v <= MOD) ? v : v % MOD;
        if (val < 0) val += MOD;
    }
    friend ostream& operator<<(ostream& os, const modular& a) { return os << a.val; }
    friend bool operator==(const modular& a, const modular& b) { return a.val == b.val; }
    friend bool operator!=(const modular& a, const modular& b) { return !(a == b); }

    modular operator-() const { return modular(-val); }
    modular& operator+=(const modular& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
    modular& operator-=(const modular& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
    modular& operator*=(const modular& m) { val = (ll)val*m.val%MOD; return *this; }
    friend modular exp(modular a, ll p) {
        modular ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;
        return ans;
    }
    friend modular inv(const modular& a) { return invGeneral(a.val,MOD); }
    // inv is equivalent to return exp(b,b.mod-2) if prime
    modular& operator/=(const modular& m) { return (*this) *= inv(m); }

    friend modular operator+(modular a, const modular& b) { return a += b; }
    friend modular operator-(modular a, const modular& b) { return a -= b; }
    friend modular operator*(modular a, const modular& b) { return a *= b; }

    friend modular operator/(modular a, const modular& b) { return a /= b; }
};

typedef modular<int> mi;
typedef pair<mi,mi> pmi;
typedef vector<mi> vmi;
typedef vector<pmi> vpmi;

int T,N,X,Y;
// ll dp[5000001];
vpi dif;
int i[2], dumb[2], dumbFac;
ll ccost;

int get(int x) {
    if (i[x]) return dif[i[x]].f;
    return dif[i[x]].f+dumb[x]*Y;
}

void adv(int x) {
    if (i[x]) i[x] ++;
    else {
        if (dumb[x] < dumbFac) dumb[x] ++;
        else i[x] ++;
    }
}

ll solve() {
    re(N,X,Y); dif = {{X+Y,1}}; if (X < Y) swap(X,Y);
    if (min(X,Y) == 0) {
    	ps((ll)(N-1)*max(X,Y));
    	exit(0);
    }
    dumbFac = (X-1)/Y; // X+Y to X+Y*(1+dumbFac)
    F0R(j,2) i[j] = dumb[j] = 0;
    // dumbFac = 0;
    int cur = dumbFac+2;
    if (N <= cur) return (ll)X*(N-1)+(ll)Y*(N-1)*N/2; // (X+Y) to (X+Y*(cur-1))
    else ccost = (ll)X*(cur-1)+(ll)Y*(cur-1)*(cur)/2;
    dumb[1] = dumbFac;

    while (cur < N) {
        // ps(cur,N,ccost);
        int mn = min(get(0)+X,get(1)+Y), num = 0;
        if (get(0)+X == mn) {
            num += dif[i[0]].s;
            adv(0);
        }
        if (get(1)+Y == mn) {
            num += dif[i[1]].s;
            adv(1);
        }
        dif.pb({mn,num}); // if (num > 1) ps(cur,mn,num);
        if (num > N-cur) return ccost+(ll)(N-cur)*mn;
        ccost += (ll)num*mn; cur += num;
    }
    return ccost;
}

int main() {
    // setIO("newlang");
    // re(T);
    F0R(i,1) ps(solve());
    // don't forget newline!
    // no range based for loops :(
    // use scanf, printf
}

/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do smth instead of nothing and stay organized
*/

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(LL x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(LL x){write(x);putchar('\n');}
int c1,c2;
map<LL,int> mp;
priority_queue<LL,vector<LL>,greater<LL> > hp;
int main()
{
	int n=read(),c1=read(),c2=read();
	hp.push(0);mp[0]=1;int tot=0;
	LL ans=0;
	while(tot<n)
	{
		LL x=hp.top();hp.pop();
		int u=min(mp[x],n-tot);
		tot+=u;ans+=1LL*u*(c1+c2);
		if(!mp[x+c1])mp[x+c1]=u,hp.push(x+c1);
		else mp[x+c1]+=u;
		if(!mp[x+c2])mp[x+c2]=u,hp.push(x+c2);
		else mp[x+c2]+=u;
	}
	pr2(ans);
	return 0;
}

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(LL x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(LL x){write(x);putchar('\n');}
int c1,c2;
map<LL,int> mp;
priority_queue<LL,vector<LL>,greater<LL> > hp;
int main()
{
	int n=read(),c1=read(),c2=read();
	hp.push(0);mp[0]=1;int tot=1;
	LL ans=0;
	while(tot<n)
	{
		LL x=hp.top();hp.pop();
		int u=min(mp[x],n-tot);
		tot+=u;ans+=1LL*u*(c1+c2)+x*u;
		if(!mp[x+c1])mp[x+c1]=u,hp.push(x+c1);
		else mp[x+c1]+=u;
		if(!mp[x+c2])mp[x+c2]=u,hp.push(x+c2);
		else mp[x+c2]+=u;
	}
	pr2(ans);
	return 0;
}

#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <bitset>
#include <random>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define vi vector<int>
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long ll;
typedef short inth;

const int N = 1;
const int M = N + 7;
const int MOD = 1e9 + 7;
const ll INF = 1e16 + 17;

ll rec(int n, int cnt) {
    if (n == 1)
        return cnt;
    if (n & 1) {
        return rec(n / 2, cnt + 1) + rec(n / 2 + 1, cnt + 1);
    } else {
        return rec(n / 2, cnt + 1) * 2;
    }
}

int main() {
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    if (a > b)
        swap(a, b);
    int m = n - 1, bits = 0;
    while (m) {
        ++bits;
        m >>= 1;
    }
    ll ans = 0;
    if (b == a) {
        ans = rec(n, 0) * a;
    } else {
        int x = (b + b - 1) / (b - a);
        for (int i = 0; i < n; ++i) {
            int cnt = __builtin_popcount(i);
            if (cnt - (bits - cnt) >= x) {
                ans += 1LL * a * cnt + 1LL * b * (bits - cnt) + a + b;
            } else {
                ans += 1LL * b * cnt + 1LL * a * (bits - cnt);
            }
        }
    }
    printf("%lld\n", ans);

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, a, b; cin >> n >> a >> b;
    if (min(a, b) == 0) {
        cout << (n - 1) * (a + b) << endl;
        return 0;
    }
    if (a > b) {
        swap(a, b);
    }
    if (true) {
        ll r = 0;
        for (int i = 0; n; i++) {
            ll x = min(n, (b / a) + 1);
            r += x * (a + b) + (x - 1) * x / 2 * a;
            r += b * x * i;
            n -= x;
        }
        return cout << r << endl, 0;
    }
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, a, b; cin >> n >> a >> b;
    map<ll,ll> m;
    m[0] = 1; n--;
    if (min(a, b) == 0) {
        cout << (n - 1) * (a + b) << endl;
        return 0;
    }
    if (a > b) {
        swap(a, b);
    }
    if (2 * a < b) {
        ll r = 0;
        for (int i = 0; n; i++) {
            ll x = min(n, (b / a) + 1);
            r += x * (a + b) + (x - 1) * x / 2 * a;
            r += b * x * i;
            n -= x;
        }
        return cout << r << endl, 0;
    }
    while (n) {
        auto x = *m.begin();
        ll f = x.first, s = x.second;
        if (s <= n) {
            m[f + a] += s;
            m[f + b] += s;
            m.erase(m.begin());
            n -= s;
        }
        else {
            m[f + a] += n;
            m[f + b] += n;
            m[f] -= n; n = 0;
        }
    }
    ll r = 0;
    for (auto x : m) {
        ll f = x.first;
        ll s = x.second;
        r += f * s;
    }
    cout << r << endl;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int n;
long long c[2];
map<long long, int> ways;

int main() {
	ways.clear();
	cin >> n >> c[0] >> c[1];
	if (c[0] > c[1]) swap(c[0], c[1]);
	if (n == 1) {
		cout << c[0] << endl;
		return 0;
	}

	if (c[0] == 0) {
		cout << c[1] * (long long)n << endl;
		return 0;
	}

	ways[c[0]] = 1;
	if (c[0] == c[1]) ways[c[0]] = 2; else ways[c[1]] = 1;
	n -= 2;

	long long ans = c[0] + c[1];
	while (n > 0) {
		map<long long, int>::iterator low = ways.lower_bound(1LL);
		long long cost = low->first;
		int num = low->second;
		ways.erase(low);

		if (n <= num) {
			ans += (long long)n * (cost + c[0] + c[1]);
			break;
		} else {
			long long left = cost + c[0];
			if (ways.find(left) == ways.end()) {
				ways[left] = num;
			} else ways[left] += num;

			long long right = cost + c[1];
			if (ways.find(right) == ways.end()) {
				ways[right] = num;
			} else ways[right] += num;

			n -= num;
			ans += (long long)num * (cost + c[0] + c[1]);
		}
	}
	cout << ans << endl;
	return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#define PB push_back
#define ll long long
#define inf 0x3f3f3f3f3f3f3f3fll
#define fill(a,b) memset(a,b,sizeof(b))
#define cpy(a,b) memcpy(a,b,sizeof(b))
template<typename T> inline bool MIN(T &a,const T &b) {return a>b? a=b,1:0;}
template<typename T> inline bool MAX(T &a,const T &b) {return a<b? a=b,1:0;}

using namespace std;
ll n,c0,c1;

ll C[20000][25];

ll calc(ll j,ll i) {
	if (i==0) return j+1;
	if (j>15000) return n;
	return C[i+j+1][i+1];
}

int ok(ll cost) {
	if (!c0) return 1;
	ll res=0;

	for (ll i=0;i<=20&&cost-i*c1>=0;++i) {
		ll j=(cost-i*c1)/c0;
		res+=calc(j,i);
		if (res>=n) return 1;
	}
	return 0;
}

int main()
{
//	freopen("B.in","r",stdin);
	scanf("%I64d%I64d%I64d",&n,&c0,&c1); --n;
	if (c0>c1) swap(c0,c1);
	C[0][0]=1;
	for (int i=1;i<20000;++i) {
		C[i][0]=1;
		for (int j=1;j<25;++j) C[i][j]=min(n,C[i-1][j-1]+C[i-1][j]);
	}

	ll l=0,r=inf;
	while (l<r) {
		ll mid=l+r>>1;
		if (ok(mid)) r=mid;
		else l=mid+1;
	}

	ll cnt=0,sum=0;
	for (ll i=0;i<=20&&(l-1)-i*c1>=0;++i) {
		ll j=((l-1)-i*c1)/c0;
		if (i==0) {
			cnt+=j+1;
			sum+=(j+1)*j/2*c0;
		} else {
			for (;j>=0;--j) {
				cnt+=C[i+j][i];
				sum+=C[i+j][i]*(c1*i+c0*j);
			}
		}
	}
//	cout<<sum<<endl;
	printf("%I64d\n",sum+l*(n-cnt)+n*(c0+c1));
	return 0;
}

#include <bits/stdc++.h>
#define intl long long
using namespace std;

map<intl,intl> st;

typedef map<intl,intl> :: iterator poi;

intl ans,a,b;
int n;
const intl base = 20000LL;

int main() {
	cin >> n >> a >> b;
	st[0] = 1; n--;
	if (a > b) swap(a, b);
	if (!a) {
		cout << b * (intl) (n - 1) << endl;
		return 0;
	}
	if (a * base < b) {
		for (int t = 0; n; t++) {
			intl N = (b / a) + 1;
			N = min(N, (intl) n);
			ans += N * (N - 1) / 2LL * a + N * b * (intl) t;
			ans += N * (a + b);
			n -= N;
		}
	}
	else while (n > 0) {
		poi q = st.begin();
		intl A = q -> first, B = q -> second;
		ans += min((intl) n, B) * A + (intl) (a + b);
		n -= B;
   		st.erase(q);
		//cout << q -> first << " " << q -> second << endl;
		st[A + (intl) a] += B;
		st[A + (intl) b] += B;
	}
	cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>
#define intl long long
using namespace std;

map<intl,intl> st;

typedef map<intl,intl> :: iterator poi;

intl ans,a,b;
int n;
const intl base = 20000LL;

int main() {
	cin >> n >> a >> b;
	st[0] = 1; n--;
	if (a > b) swap(a, b);
	if (!a) {
		cout << b * (intl) (n - 1) << endl;
		return 0;
	}
	if (a * base < b) {
		for (int t = 0; n; t++) {
			intl N = (b / a) + 1;
			N = min(N, (intl) n);
			ans += N * (N - 1) / 2LL * a + N * b * (intl) t;
			ans += N * (a + b);
			n -= N;
		}
	}
	else while (n > 0) {
		poi q = st.begin();
		intl A = q -> first, B = q -> second;
		ans += min((intl) n, B) * (A + (intl) (a + b));
		n -= B;
   		st.erase(q);
		//cout << q -> first << " " << q -> second << endl;
		st[A + (intl) a] += B;
		st[A + (intl) b] += B;
	}
	cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int n, c0, c1;

long long calc(long long x, long long bound) {
	long long cnt = 0;

	for (int i = 0; ; ++i) {
		long long now = x - 1LL * i * c1;
		if (now < 0) break;
		cnt += now / c0 + 1;
		if (cnt >= bound) return bound;
	}

	return cnt;
}

long long sum(long long x) {
	long long s = 0;

	for (int i = 0; ; ++i) {
		long long now = x - 1LL * i * c1;
		if (now < 0) break;
		long long cnt = now / c0;
		s += (1LL * i * c1) * (cnt + 1);
		s += (1LL*(2*c0 + 1LL*(cnt - 1)*c0)*cnt)/2;
	}

	return s;
}

int main() {
	cin >> n >> c0 >> c1;
	if (c0 > c1) swap(c0, c1);
	if (c0 == 0) {
		cout << 1LL * (n - 1) * c1 << endl;
		return 0;
	}
	long long l, r;

	l = 0, r = c1 * 30;
	while (r - l > 1) {
		long long m = (l + r) / 2;
		if (calc(m, n - 1) == n - 1) r = m; else l = m;
	}

	long long result = 1LL * (c0 + c1) * (n - 1);
	result += r * (n - 1 - calc(r - 1, n - 1));
	result += sum(r - 1);

	cout << result << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int n, c0, c1;

long long calc(long long x, long long bound) {
	long long cnt = 0;

	for (int i = 0; ; ++i) {
		long long now = x - 1LL * i * c1;
		if (now < 0) break;
		cnt += now / c0 + 1;
		if (cnt >= bound) return bound;
	}

	return cnt;
}

long long sum(long long x) {
	long long s = 0;

	for (int i = 0; ; ++i) {
		long long now = x - 1LL * i * c1;
		if (now < 0) break;
		long long cnt = now / c0;
		s += (1LL * i * c1) * (cnt + 1);
		s += (1LL*(2*c0 + 1LL*(cnt - 1)*c0)*cnt)/2;
	}

	return s;
}

int main() {
	cin >> n >> c0 >> c1;
	if (c0 > c1) swap(c0, c1);
	if (c0 == 0) {
		cout << 1LL * (n - 1) * c1 << endl;
		return 0;
	}
	long long l, r;

	l = 0, r = 1LL * c1 * 30;
	while (r - l > 1) {
		long long m = (l + r) / 2;
		if (calc(m, n - 1) == n - 1) r = m; else l = m;
	}

	long long result = 1LL * (c0 + c1) * (n - 1);
	result += r * (n - 1 - calc(r - 1, n - 1));
	result += sum(r - 1);

	cout << result << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    int c0, c1;
    cin >> n;
    cin >> c0 >> c1;
    deque<pair<int64_t, int> > ends_0;
    deque<pair<int64_t, int> > ends_1;

    if (c0 > c1)
      swap(c0, c1);
    if (c0 == 0) {
      cout << n*c1 << '\n';
      return 0;
    }

    ends_0.push_back({c0, 1});
    ends_1.push_back({c1, 1});
    int64_t total = c0 + c1;

    auto add = [](int cost, int cnt, deque<pair<int64_t, int> >& v) {
      if (!v.empty() && v.back().first == cost) {
	v.back().second += cnt;
      } else {
	v.emplace_back(cost, cnt);
      }
    };

    int have = 2;
    while (have < n) {
      int64_t cost;
      int cnt;
      if (ends_0.front().first < ends_1.front().first) {
	tie(cost, cnt) = ends_0.front();
	ends_0.pop_front();
      } else {
	tie(cost, cnt) = ends_1.front();
	ends_1.pop_front();
      }

      add(cost+c0, cnt, ends_0);
      int add_1 = min(n, have+cnt) - have;
      have += add_1;
      total += add_1*(cost + c0 + c1);
      add(cost+c1, add_1, ends_1);
    }
    cout << total << "\n";
}

#include <bits/stdc++.h>

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    int c0, c1;
    cin >> n;
    cin >> c0 >> c1;
    deque<pair<int64_t, int> > ends_0;
    deque<pair<int64_t, int> > ends_1;

    if (c0 > c1)
      swap(c0, c1);
    if (c0 == 0) {
      cout << (n-1)*c1 << '\n';
      return 0;
    }

    ends_0.push_back({c0, 1});
    ends_1.push_back({c1, 1});
    int64_t total = c0 + c1;

    auto add = [](int cost, int cnt, deque<pair<int64_t, int> >& v) {
      if (!v.empty() && v.back().first == cost) {
	v.back().second += cnt;
      } else {
	v.emplace_back(cost, cnt);
      }
    };

    int have = 2;
    while (have < n) {
      int64_t cost;
      int cnt;
      if (ends_0.front().first < ends_1.front().first) {
	tie(cost, cnt) = ends_0.front();
	ends_0.pop_front();
      } else {
	tie(cost, cnt) = ends_1.front();
	ends_1.pop_front();
      }

      add(cost+c0, cnt, ends_0);
      int add_1 = min(n, have+cnt) - have;
      have += add_1;
      total += add_1*(cost + c0 + c1);
      add(cost+c1, add_1, ends_1);
    }
    cout << total << "\n";
}

#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<ctime>
#include<vector>
#include<string>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
using namespace std;
struct pp
{
    long long cost;
    bool operator <(const pp &temp)const
    {
        return cost<temp.cost;
    }
};
map<pp,int>hs;
int n,c[2];
pp now;
map<pp,int> solve(int n)
{
    map<pp,int>ret,ms;
    map<pp,int>::iterator it;
    pp u,now;
    ret.clear();
	if(n<=3)
    {
        now.cost=c[0];
        ret[now]++;
        now.cost=c[1];
        ret[now]++;
    }
    if(n==2)
       return ret;
    if(n>3)
        ret=solve(n/2);
    int nc=0,vl;
   // printf("n=%d,ret.size()=%d\n",n,ret.size());
    while(n>3&&nc<n/2)
    {
        it=ret.begin();
		if(nc+it->second>=n/2)
            vl=n/2-nc;
        else
            vl=it->second;
         u=it->first;
         ret[u]-=vl;
         if(ret[u]==0)
            ret.erase(u);
         nc+=vl;
         now=u;
         now.cost+=c[0];
         ret[now]+=vl;
         now=u;
         now.cost+=c[1];
         ret[now]+=vl;
    }
    if(n&1)
    {
        it=ret.begin();
        u=it->first;
        ret[u]--;
        if(ret[u]==0)
            ret.erase(u);
        now=u;
        now.cost+=c[0];
        ret[now]++;
        now=u;
        now.cost+=c[1];
        ret[now]++;
    }
    return ret;
}
int main()
{
    scanf("%d%d%d",&n,&c[0],&c[1]);
    if(c[0]==0||c[1]==0)
    {
    	printf("%lld\n",(long long)(n-1)*(long long)max(c[0],c[1]));
    }
	hs=solve(n);
    map<pp,int>::iterator it;
    pp u;
    long long ans=0;
    for(it=hs.begin();it!=hs.end();it++)
    {
         u=it->first;
         ans+=(long long)u.cost*(long long)hs[u];
    }
    printf("%lld\n",ans);
    return 0;
}
/*
100000000 1 3

*/

#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<ctime>
#include<vector>
#include<string>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
using namespace std;
struct pp
{
    long long cost;
    bool operator <(const pp &temp)const
    {
        return cost<temp.cost;
    }
};
map<pp,int>hs;
int n,c[2];
pp now;
map<pp,int> solve(int n)
{
    map<pp,int>ret,ms;
    map<pp,int>::iterator it;
    pp u,now;
    ret.clear();
    if(n==2)
    {
        now.cost=c[0];
        ret[now]++;
        now.cost=c[1];
        ret[now]++;
        return ret;
    }
    if(n==1)
    {
   	     now.cost=min(c[0],c[1]);
   	     ret[now]++;
   	     return ret;
    }
    ret=solve(n/2);
    int nc=0,vl;
    while(nc<n/2)
    {
        it=ret.begin();
        if(nc+it->second>=n/2)
            vl=n/2-nc;
        else
            vl=it->second;
         u=it->first;
         ret[u]-=vl;
         if(ret[u]==0)
            ret.erase(u);
         nc+=vl;
         now=u;
         now.cost+=c[0];
         ret[now]+=vl;
         now=u;
         now.cost+=c[1];
         ret[now]+=vl;
    }
    if(n&1)
    {
        it=ret.begin();
        u=it->first;
        ret[u]--;
        if(ret[u]==0)
            ret.erase(u);
        now=u;
        now.cost+=c[0];
        ret[now]++;
        now=u;
        now.cost+=c[1];
        ret[now]++;
    }
    return ret;
}
int main()
{
    scanf("%d%d%d",&n,&c[0],&c[1]);
    hs=solve(n);
    map<pp,int>::iterator it;
    pp u;
    long long ans=0;
    for(it=hs.begin();it!=hs.end();it++)
    {
         u=it->first;
         ans+=(long long)u.cost*(long long)hs[u];
    }
    printf("%lld\n",ans);
    return 0;
}

#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<ctime>
#include<vector>
#include<string>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
using namespace std;
struct pp
{
    long long cost;
    bool operator <(const pp &temp)const
    {
        return cost<temp.cost;
    }
};
map<pp,int>hs;
int n,c[2];
pp now;
map<pp,int> solve(int n)
{
    map<pp,int>ret,ms;
    map<pp,int>::iterator it;
    pp u,now;
    ret.clear();
	if(n<=3)
    {
        now.cost=c[0];
        ret[now]++;
        now.cost=c[1];
        ret[now]++;
    }
    if(n==2)
       return ret;
    if(n>3)
        ret=solve(n/2);
    int nc=0,vl;
   // printf("n=%d,ret.size()=%d\n",n,ret.size());
    while(n>3&&nc<n/2)
    {
        it=ret.begin();
		if(nc+it->second>=n/2)
            vl=n/2-nc;
        else
            vl=it->second;
         u=it->first;
         ret[u]-=vl;
         if(ret[u]==0)
            ret.erase(u);
         nc+=vl;
         now=u;
         now.cost+=c[0];
         ret[now]+=vl;
         now=u;
         now.cost+=c[1];
         ret[now]+=vl;
    }
    if(n&1)
    {
        it=ret.begin();
        u=it->first;
        ret[u]--;
        if(ret[u]==0)
            ret.erase(u);
        now=u;
        now.cost+=c[0];
        ret[now]++;
        now=u;
        now.cost+=c[1];
        ret[now]++;
    }
    return ret;
}
int main()
{
    scanf("%d%d%d",&n,&c[0],&c[1]);
    if(c[0]==0||c[1]==0)
    {
    	printf("%lld\n",(n-1)*max(c[0],c[1]));
    }
	hs=solve(n);
    map<pp,int>::iterator it;
    pp u;
    long long ans=0;
    for(it=hs.begin();it!=hs.end();it++)
    {
         u=it->first;
         ans+=(long long)u.cost*(long long)hs[u];
    }
    printf("%lld\n",ans);
    return 0;
}
/*
100000000 1 3

*/

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using db = double;
using vi = vector<int>;
#define pb push_back
const ll mod1 = (ll)1e9+9;
const ll mod2 = (ll)1e9+7;

ll n, c0, c1;

ll getmul(ll a, ll k, ll mod) {
	ll ret = 1;
	while (k > 0) {
		if (k & 1) ret = (ret * a) % mod;
		k /= 2;
		a = (a*a) % mod;
	}
	return ret;
}

ll C(ll n, ll m) {
	ll r1 = 1, r2 = 1;
	for (ll i = 1; i <= m; ++i) {
		r1 = (r1 * (n-i+1)) % mod1 * getmul(i,mod1-2,mod1) % mod1;
		r2 = (r2 * (n-i+1)) % mod2 * getmul(i,mod2-2,mod2) % mod2;
	}
	if (r1 != r2) return -1;
	return r1;
}

bool check(ll c) {
	//cout<<c<<endl;
	ll sum = 0;
	for (ll i = 0; i*c0 <= c; ++i) {
		ll j = (c-i*c0)/c1;
		ll tmp = C(i+j+1,i+1);
		//cout<<i<<' '<<j<<' '<<tmp<<endl;
		if (tmp == -1) return true;
		sum += tmp;
		if (sum >= n-1) return true;
	}
	return false;
}

void solve(ll c) {
	cout<<c<<endl;
	ll ans = 0;
	ll sum = 0;
	for (ll i = 0; i*c0 <= c; ++i) {
		if (i == 0) {
			ll t = c/c1+1;
			ans += ((t-1)*c1)*t/2;
			sum += t;
		}
		else {
			for (ll j = 0; i*c0+j*c1 <= c; ++j) {
				ll t = min(sum, C(i+j,i));
				ans += t*(i*c0+j*c1);
				sum += t;
			}
		}
	}
	cout<<ans-(sum-(n-1))*c+(c0+c1)*(n-1)<<endl;
}

int main() {
	cin>>n>>c0>>c1;
	if (c0*c1 == 0) {
		cout<<ll(n-1)*(c0+c1)<<endl;
		return 0;
	}
	if (c0 < c1) swap(c0, c1);
	ll l = 0, r = c1*n*100;
	while (l + 1 < r) {
		ll m = (l + r) / 2;
		if (check(m)) r = m;
		else l = m;
	}
	solve(r);
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using db = double;
using vi = vector<int>;
#define pb push_back
const ll mod1 = (ll)1e9+9;
const ll mod2 = (ll)1e9+7;

int n, c0, c1;

ll getmul(ll a, ll k, ll mod) {
	ll ret = 1;
	while (k > 0) {
		if (k & 1) ret = (ret * a) % mod;
		k /= 2;
		a = (a*a) % mod;
	}
	return ret;
}

ll C(ll n, ll m) {
	ll r1 = 1, r2 = 1;
	for (ll i = 1; i <= m; ++i) {
		r1 = (r1 * (n-i+1)) % mod1 * getmul(i,mod1-2,mod1) % mod1;
		r2 = (r2 * (n-i+1)) % mod2 * getmul(i,mod2-2,mod2) % mod2;
	}
	if (r1 != r2) return -1;
	return r1;
}

bool check(ll c) {
	//cout<<c<<endl;
	ll sum = 0;
	for (ll i = 0; i*c0 <= c; ++i) {
		ll j = (c-i*c0)/c1;
		ll tmp = C(i+j+1,i+1);
		//cout<<i<<' '<<j<<' '<<tmp<<endl;
		if (tmp == -1) return true;
		sum += tmp;
		if (sum >= n-1) return true;
	}
	return false;
}

void solve(ll c) {
	//cout<<c<<endl;
	ll ans = 0;
	ll sum = n-1;
	for (ll i = 0; i*c0 <= c; ++i) {
		if (i == 0) {
			ll t = min(sum, c/c1);
			ans += ((t-1)*c1)*t/2;
			sum -= t;
		}
		else {
			for (ll j = 0; i*c0+j*c1 <= c; ++j) {
				ll t = min(sum, C(i+j,i));
				ans += t*(i*c0+j*c1);
				sum -= t;
			}
		}
	}
	cout<<ans+(c0+c1)*(n-1)<<endl;
}

int main() {
	scanf( "%d%d%d", &n, &c0, &c1 );
	if (c0*c1 == 0) {
		puts( "0" );
		return 0;
	}
	if (c0 < c1) swap(c0, c1);
	ll l = 0, r = c1*n*100;
	while (l + 1 < r) {
		ll m = (l + r) / 2;
		if (check(m)) r = m;
		else l = m;
	}
	solve(r);
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using db = double;
using vi = vector<int>;
#define pb push_back
const ll mod1 = (ll)1e9+9;
const ll mod2 = (ll)1e9+7;

ll n, c0, c1;

ll getmul(ll a, ll k, ll mod) {
	ll ret = 1;
	while (k > 0) {
		if (k & 1) ret = (ret * a) % mod;
		k /= 2;
		a = (a*a) % mod;
	}
	return ret;
}

ll C(ll n, ll m) {
	ll r1 = 1, r2 = 1;
	for (ll i = 1; i <= m; ++i) {
		r1 = (r1 * (n-i+1)) % mod1 * getmul(i,mod1-2,mod1) % mod1;
		r2 = (r2 * (n-i+1)) % mod2 * getmul(i,mod2-2,mod2) % mod2;
	}
	if (r1 != r2) return -1;
	return r1;
}

bool check(ll c) {
	//cout<<c<<endl;
	ll sum = 0;
	for (ll i = 0; i*c0 <= c; ++i) {
		ll j = (c-i*c0)/c1;
		ll tmp = C(i+j+1,i+1);
		//cout<<i<<' '<<j<<' '<<tmp<<endl;
		if (tmp == -1) return true;
		sum += tmp;
		if (sum >= n-1) return true;
	}
	return false;
}

void solve(ll c) {
	//cout<<c<<endl;
	ll ans = 0;
	ll sum = n-1;
	for (ll i = 0; i*c0 <= c; ++i) {
		if (i == 0) {
			ll t = min(sum, c/c1);
			ans += ((t-1)*c1)*t/2;
			sum -= t;
		}
		else {
			for (ll j = 0; i*c0+j*c1 <= c; ++j) {
				ll t = min(sum, C(i+j,i));
				ans += t*(i*c0+j*c1);
				sum -= t;
			}
		}
	}
	cout<<ans+(c0+c1)*(n-1)<<endl;
}

int main() {
	cin>>n>>c0>>c1;
	if (c0*c1 == 0) {
		cout<<ll(n-1)*(c0+c1)<<endl;
		return 0;
	}
	if (c0 < c1) swap(c0, c1);
	ll l = 0, r = c1*n*100;
	while (l + 1 < r) {
		ll m = (l + r) / 2;
		if (check(m)) r = m;
		else l = m;
	}
	solve(r);
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using db = double;
using vi = vector<int>;
#define pb push_back
const ll mod1 = (ll)1e9+3;
const ll mod2 = (ll)1e9+7;

int n, c0, c1;

ll getmul(ll a, ll k, ll mod) {
	ll ret = 1;
	while (k > 1) {
		if (k & 1) ret = (ret * a) % mod;
		k /= 2;
		a = (a*a) % mod;
	}
	return ret;
}

ll C(ll n, ll m) {
	ll r1 = 1, r2 = 1;
	for (ll i = 1; i <= m; ++i) {
		r1 = (r1 * (n-i+1)) % mod1 * getmul(i,mod1-2,mod1) % mod1;
		r2 = (r2 * (n-i+1)) % mod2 * getmul(i,mod2-2,mod2) % mod2;
	}
	if (r1 != r2) return -1;
	return r1;
}

bool check(ll c) {
	//cout<<c<<endl;
	ll sum = 0;
	for (ll i = 0; i*c0 <= c; ++i) {
		ll j = (c-i*c0)/c1;
		ll tmp = C(i+j+1,i+1);
		//cout<<i<<' '<<j<<' '<<tmp<<endl;
		if (tmp == -1) return true;
		sum += tmp;
		if (sum >= n-1) return true;
	}
	return false;
}

void solve(ll c) {
	ll ans = 0;
	ll sum = n-1;
	for (ll i = 0; i*c0 <= c; ++i) {
		if (i == 0) {
			ll t = min(sum, c/c1);
			ans += ((t-1)*c1)*t/2;
			sum -= t;
		}
		else {
			for (ll j = 0; i*c0+j*c1 <= c; ++j) {
				ll t = min(sum, C(i+j,i));
				ans += t*(i*c0+j*c1);
				sum -= t;
			}
		}
	}
	cout<<ans+(c0+c1)*(n-1)<<endl;
}

int main() {
	scanf( "%d%d%d", &n, &c0, &c1 );
	if (c0+c1 == 0) {
		puts( "0" );
		return 0;
	}
	if (c0 < c1) swap(c0, c1);
	ll l = 0, r = c1*n*100;
	while (l + 1 < r) {
		ll m = (l + r) / 2;
		if (check(m)) r = m;
		else l = m;
	}
	solve(r);
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using db = double;
using vi = vector<int>;
#define pb push_back
const ll mod1 = (ll)1e9+9;
const ll mod2 = (ll)1e9+7;

int n, c0, c1;

ll getmul(ll a, ll k, ll mod) {
	ll ret = 1;
	while (k > 0) {
		if (k & 1) ret = (ret * a) % mod;
		k /= 2;
		a = (a*a) % mod;
	}
	return ret;
}

ll C(ll n, ll m) {
	ll r1 = 1, r2 = 1;
	for (ll i = 1; i <= m; ++i) {
		r1 = (r1 * (n-i+1)) % mod1 * getmul(i,mod1-2,mod1) % mod1;
		r2 = (r2 * (n-i+1)) % mod2 * getmul(i,mod2-2,mod2) % mod2;
	}
	if (r1 != r2) return -1;
	return r1;
}

bool check(ll c) {
	//cout<<c<<endl;
	ll sum = 0;
	for (ll i = 0; i*c0 <= c; ++i) {
		ll j = (c-i*c0)/c1;
		ll tmp = C(i+j+1,i+1);
		//cout<<i<<' '<<j<<' '<<tmp<<endl;
		if (tmp == -1) return true;
		sum += tmp;
		if (sum >= n-1) return true;
	}
	return false;
}

void solve(ll c) {
	//cout<<c<<endl;
	ll ans = 0;
	ll sum = n-1;
	for (ll i = 0; i*c0 <= c; ++i) {
		if (i == 0) {
			ll t = min(sum, c/c1);
			ans += ((t-1)*c1)*t/2;
			sum -= t;
		}
		else {
			for (ll j = 0; i*c0+j*c1 <= c; ++j) {
				ll t = min(sum, C(i+j,i));
				ans += t*(i*c0+j*c1);
				sum -= t;
			}
		}
	}
	cout<<ans+(c0+c1)*(n-1)<<endl;
}

int main() {
	scanf( "%d%d%d", &n, &c0, &c1 );
	if (c0*c1 == 0) {
		cout<<ll(n-1)*(c0+c1)<<endl;
		return 0;
	}
	if (c0 < c1) swap(c0, c1);
	ll l = 0, r = c1*n*100;
	while (l + 1 < r) {
		ll m = (l + r) / 2;
		if (check(m)) r = m;
		else l = m;
	}
	solve(r);
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const ll inf=1000000000000000000ll;
ll gcd(ll x,ll y)
{
	return y==0?x:gcd(y,x%y);
}
ll c1,c2,n,pp,re,sp;
ll c(ll x,ll y)
{
	if (x-y<y) y=x-y;
	if (y<=0) return 1;
	if (y==1) return x;
	ll re=1;
	fo(i,1,y)
	{
		ll g=gcd(re,i),tp=(y-x+i);
		re/=g;
		re=re*(tp/(i/g));
		if (re%tp || re<=0 || re>n) return inf;
	}
	return re;
}
bool check(ll mid)
{
	pp=0; re=0; ll up=mid/c2;
	ll last=-1;
	pp=0;ll calc=0;
	fd(l,up,0)
	{
		ll num=(mid-l*c2)/c1;
		if (l==0)
		{
			calc=1;
			pp+=calc;
			re+=calc*c1*(last+1);
			if (pp>=n) return 1;
			continue;
		}
		if (l==1 && sp)
		{
			pp+=max(num-last-1,0ll);
			if (pp>=n) return 1;
		} else
		{
			fd(j,num,last+2)
			{
				calc=c(j+l-1,l-1);
				pp+=calc;
				re+=calc*(l*c2+j*c1);
				if (pp>=n) return 1;
			}
		}
		calc=c(l+last+1,last+1);
		pp+=calc;
		re+=calc*(l*c2+(last+1)*c1);
		if (pp>=n) return 1;
		last=num;
	}
	if (pp>=n) return 1;
	return 0;
}
int main()
{
	cin>>n>>c1>>c2;
	if (c1>c2) swap(c1,c2);
	if (c1==0)
	{
		cout<<c2*(n-1);
		return 0;
	}
	ll gp=gcd(c1,c2);
	c1/=gp; c2/=gp;
	ll l=0,r=1000000000000000000ll,ans=0;
	sp=1;
	while (l<=r)
	{
		ll mid=(l+r)/2;
		if (check(mid)) ans=mid,r=mid-1; else l=mid+1;
	}
	sp=0;
	pp=0;
	check(ans-1);
	ll rem=(n-pp);
	re=re+rem*ans+rem*c1;
	cout<<re*gp;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<iostream>
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const ll inf=1000000000000000000ll;
ll gcd(ll x,ll y)
{
	return y==0?x:gcd(y,x%y);
}
ll c(ll x,ll y)
{
	if (x-y<y) y=x-y;
	if (y<=0) return 1;
	if (y==1) return x;
	ll re=1;
	fo(i,1,y)
	{
		//re=re*(x-y+i)/y;
		ll g=gcd(re,y),tp=(x-y+i);
		re/=g; y/=g; tp/=y;
		re*=tp;
		if (re%tp || re<=0) return inf;
	}
	return re;
}
ll c1,c2,n,pp,re,sp;
bool check(ll mid)
{
	pp=0; re=0; ll up=mid/c2;
	ll last=-1;
	pp=0;ll calc=0;
	fd(l,up,0)
	{
		ll num=(mid-l*c2)/c1;
		if (l==0)
		{
			calc=1;
			pp+=calc;
			re+=calc*c1*(last+1);
			if (pp>=n) return 1;
			continue;
		}
		if (l==1 && sp)
		{
			pp+=max(num-last-1,0ll);
			if (pp>=n) return 1;
		} else
		{
			fd(j,num,last+2)
			{
				calc=c(j+l-1,l-1);
				pp+=calc;
				re+=calc*(l*c2+j*c1);
				if (pp>=n) return 1;
			}
		}
		calc=c(l+last+1,last+1);
		pp+=calc;
		re+=calc*(l*c2+(last+1)*c1);
		if (pp>=n) return 1;
		last=num;
	}
	return 0;
}
int main()
{
	//scanf("%I64d%I64d%I64d",&n,&c1,&c2);
	cin>>n>>c1>>c2;
	if (c1>c2) swap(c1,c2);
	if (c1==0)
	{
		cout<<c2*(n-1);
		return 0;
	}
	ll gp=1;
	c1/=gp; c2/=gp;
	ll l=0,r=10000000000000000ll,ans=0;
	sp=1;
	while (l<=r)
	{
		ll mid=(l+r)>>1;
		if (check(mid)) ans=mid,r=mid-1; else l=mid+1;
	}
	sp=0;
	pp=0;
	check(ans-1);
	ll rem=(n-pp);
	re=re+rem*((ans-c2)+c1+c2);
	cout<<re*gp;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const ll inf=1000000000000000000ll;
ll gcd(ll x,ll y)
{
	return y==0?x:gcd(y,x%y);
}
ll c1,c2,n,pp,re,sp;
ll c(ll x,ll y)
{
	if (x-y<y) y=x-y;
	if (y<=0) return 1;
	if (y==1) return x;
	ll re=1;
	fo(i,1,y)
	{
		ll g=gcd(re,y),tp=(x-y+i);
		re/=g; y/=g; tp/=y;
		re*=tp;
		if (re%tp || re<=0 || re>n) return inf;
	}
	return re;
}
bool check(ll mid)
{
	pp=0; re=0; ll up=mid/c2;
	ll last=-1;
	pp=0;ll calc=0;
	fd(l,up,0)
	{
		ll num=(mid-l*c2)/c1;
		if (l==0)
		{
			calc=1;
			pp+=calc;
			re+=calc*c1*(last+1);
			if (pp>n) return 1;
			continue;
		}
		if (l==1 && sp)
		{
			pp+=max(num-last-1,0ll);
			if (pp>n) return 1;
		} else
		{
			fd(j,num,last+2)
			{
				calc=c(j+l-1,l-1);
				pp+=calc;
				re+=calc*(l*c2+j*c1);
				if (pp>n) return 1;
			}
		}
		calc=c(l+last+1,last+1);
		pp+=calc;
		re+=calc*(l*c2+(last+1)*c1);
		if (pp>=n) return 1;
		last=num;
	}
	if (pp>n) return 1;
	return 0;
}
int main()
{
	//scanf("%I64d%I64d%I64d",&n,&c1,&c2);
	cin>>n>>c1>>c2;
	if (c1>c2) swap(c1,c2);
	if (c1==0)
	{
		cout<<c2*(n-1);
		return 0;
	}
	ll gp=1;
	c1/=gp; c2/=gp;
	ll l=0,r=1000000000000000000ll,ans=0;
	sp=1;
	while (l<=r)
	{
		ll mid=(l+r)/2;
		if (check(mid)) ans=mid,r=mid-1; else l=mid+1;
	}
	sp=0;
	pp=0;
	check(ans-1);
	ll rem=(n-pp);
	re=re+rem*ans+rem*c1;
	cout<<re*gp;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const ll inf=1000000000000000000ll;
ll gcd(ll x,ll y)
{
	return y==0?x:gcd(y,x%y);
}
ll c1,c2,n,pp,re,sp;
ll c(ll x,ll y)
{
	if (x-y<y) y=x-y;
	if (y<=0) return 1;
	if (y==1) return x;
	ll re=1;
	fo(i,1,y)
	{
		ll g=gcd(re,i),tp=(y-x+i);
		re/=g; tp/=(i/g);
		re=re*tp;
		if (re%tp || re<=0 || re>n) return inf;
	}
	return re;
}
bool check(ll mid)
{
	pp=0; re=0; ll up=mid/c2;
	ll last=-1;
	pp=0;ll calc=0;
	fd(l,up,0)
	{
		ll num=(mid-l*c2)/c1;
		if (l==0)
		{
			calc=1;
			pp+=calc;
			re+=calc*c1*(last+1);
			if (pp>=n) return 1;
			continue;
		}
		if (l==1 && sp)
		{
			pp+=max(num-last-1,0ll);
			if (pp>=n) return 1;
		} else
		{
			fd(j,num,last+2)
			{
				calc=c(j+l-1,l-1);
				pp+=calc;
				re+=calc*(l*c2+j*c1);
				if (pp>=n) return 1;
			}
		}
		calc=c(l+last+1,last+1);
		pp+=calc;
		re+=calc*(l*c2+(last+1)*c1);
		if (pp>=n) return 1;
		last=num;
	}
	if (pp>=n) return 1;
	return 0;
}
int main()
{
	cin>>n>>c1>>c2;
	if (c1>c2) swap(c1,c2);
	if (c1==0)
	{
		cout<<c2*(n-1);
		return 0;
	}
	ll gp=gcd(c1,c2);
	c1/=gp; c2/=gp;
	ll l=0,r=1000000000000000000ll,ans=0;
	sp=1;
	while (l<=r)
	{
		ll mid=(l+r)/2;
		if (check(mid)) ans=mid,r=mid-1; else l=mid+1;
	}
	sp=0;
	pp=0;
	check(ans-1);
	ll rem=(n-pp);
	re=re+rem*ans+rem*c1;
	cout<<re*gp;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<iostream>
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const ll inf=1000000000000000000ll;
ll gcd(ll x,ll y)
{
	return y==0?x:gcd(y,x%y);
}
ll c1,c2,n,pp,re,sp;
ll c(ll x,ll y)
{
	if (x-y<y) y=x-y;
	if (y<=0) return 1;
	if (y==1) return x;
	ll re=1;
	fo(i,1,y)
	{
		//re=re*(x-y+i)/y;
		ll g=gcd(re,y),tp=(x-y+i);
		re/=g; y/=g; tp/=y;
		re*=tp;
		if (re%tp || re<=0 || re>=n) return inf;
	}
	return re;
}
bool check(ll mid)
{
	pp=0; re=0; ll up=mid/c2;
	ll last=-1;
	pp=0;ll calc=0;
	fd(l,up,0)
	{
		ll num=(mid-l*c2)/c1;
		if (l==0)
		{
			calc=1;
			pp+=calc;
			re+=calc*c1*(last+1);
			if (pp>=n) return 1;
			continue;
		}
		if (l==1 && sp)
		{
			pp+=max(num-last-1,0ll);
			if (pp>=n) return 1;
		} else
		{
			fd(j,num,last+2)
			{
				calc=c(j+l-1,l-1);
				pp+=calc;
				re+=calc*(l*c2+j*c1);
				if (pp>=n) return 1;
			}
		}
		calc=c(l+last+1,last+1);
		pp+=calc;
		re+=calc*(l*c2+(last+1)*c1);
		if (pp>=n) return 1;
		last=num;
	}
	return 0;
}
int main()
{
	//scanf("%I64d%I64d%I64d",&n,&c1,&c2);
	cin>>n>>c1>>c2;
	if (c1>c2) swap(c1,c2);
	if (c1==0)
	{
		cout<<c2*(n-1);
		return 0;
	}
	ll gp=1;
	c1/=gp; c2/=gp;
	ll l=0,r=10000000000000000ll,ans=0;
	sp=1;
	while (l<=r)
	{
		ll mid=(l+r)/2;
		if (check(mid)) ans=mid,r=mid-1; else l=mid+1;
	}
	sp=0;
	pp=0;
	check(ans-1);
	ll rem=(n-pp);
	re=re+rem*ans+rem*c1;
	cout<<re*gp;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const ll inf=1000000000000000000ll;
ll gcd(ll x,ll y)
{
	return y==0?x:gcd(y,x%y);
}
ll c1,c2,n,pp,re,sp;
ll c(ll x,ll y)
{
	if (x-y<y) y=x-y;
	if (y<=0) return 1;
	if (y==1) return x;
	ll re=1;
	fo(i,1,y)
	{
		ll g=gcd(re,i),tp=(y-x+1);
		re/=g;
		re=re*(tp/(i/g));
		if (re%tp || re<=0 || re>n) return inf;
	}
	return re;
}
bool check(ll mid)
{
	pp=0; re=0; ll up=mid/c2;
	ll last=-1;
	pp=0;ll calc=0;
	fd(l,up,0)
	{
		ll num=(mid-l*c2)/c1;
		if (l==0)
		{
			calc=1;
			pp+=calc;
			re+=calc*c1*(last+1);
			if (pp>=n) return 1;
			continue;
		}
		if (l==1 && sp)
		{
			pp+=max(num-last-1,0ll);
			if (pp>=n) return 1;
		} else
		{
			fd(j,num,last+2)
			{
				calc=c(j+l-1,l-1);
				pp+=calc;
				re+=calc*(l*c2+j*c1);
				if (pp>=n) return 1;
			}
		}
		calc=c(l+last+1,last+1);
		pp+=calc;
		re+=calc*(l*c2+(last+1)*c1);
		if (pp>=n) return 1;
		last=num;
	}
	if (pp>=n) return 1;
	return 0;
}
int main()
{
	cin>>n>>c1>>c2;
	if (c1>c2) swap(c1,c2);
	if (c1==0)
	{
		cout<<c2*(n-1);
		return 0;
	}
	ll gp=gcd(c1,c2);
	c1/=gp; c2/=gp;
	ll l=0,r=1000000000000000000ll,ans=0;
	sp=1;
	while (l<=r)
	{
		ll mid=(l+r)/2;
		if (check(mid)) ans=mid,r=mid-1; else l=mid+1;
	}
	sp=0;
	pp=0;
	check(ans-1);
	ll rem=(n-pp);
	re=re+rem*ans+rem*c1;
	cout<<re*gp;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<iostream>
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const ll inf=100000000000000000ll;
ll gcd(ll x,ll y)
{
	return y==0?x:gcd(y,x%y);
}
ll c(ll x,ll y)
{
	if (y<=0) return 1;
	if (x-y<y) y=x-y;
	if (y==1) return x;
	ll re=1;
	fo(i,1,y)
	{
		//re=re*(x-y+i)/y;
		ll g=gcd(re,y),tp=(x-y+i);
		re/=g; y/=g; tp/=y;
		re*=tp;
		if (re%tp) return inf;
	}
	return re;
}
ll c1,c2,n,pp,re,sp;
bool check(ll mid)
{
	pp=0; re=0; ll up=mid/c2;
	ll last=-1;
	pp=0;ll calc=0;
	fd(l,up,0)
	{
		ll num=(mid-l*c2)/c1;
		if (l==0)
		{
			calc=1;
			pp+=calc;
			re+=calc*c1*(last+1);
			if (pp>=n) return 1;
			continue;
		}
		if (l==1 && sp)
		{
			pp+=max(num-last-1,0ll);
		} else
		{
			fd(j,num,last+2)
			{
				calc=c(j+l-1,l-1);
				pp+=calc;
				re+=calc*(l*c2+j*c1);
				if (pp>=n) return 1;
			}
		}
		calc=c(l+last+1,last+1);
		pp+=calc;
		re+=calc*(l*c2+(last+1)*c1);
		if (pp>=n) return 1;
		last=num;
	}
	return 0;
}
int main()
{
	//scanf("%I64d%I64d%I64d",&n,&c1,&c2);
	cin>>n>>c1>>c2;
	if (c1>c2) swap(c1,c2);
	if (c1==0)
	{
		cout<<c2*(n-1);
		return 0;
	}
	ll gp=1;//gcd(c1,c2);
	c1/=gp; c2/=gp;
	ll l=0,r=10000000000000000ll,ans=0;
	sp=1;
	while (l<=r)
	{
		ll mid=(l+r)>>1;
		if (check(mid)) ans=mid,r=mid-1; else l=mid+1;
	}
	sp=0;
	pp=0;
	check(ans-1);
	ll rem=(n-pp);
	re=re+rem*((ans-c2)+c1+c2);
	cout<<re*gp;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<iostream>
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const ll inf=100000000000000000ll;
ll gcd(ll x,ll y)
{
	return y==0?x:gcd(y,x%y);
}
ll c(ll x,ll y)
{
	if (y<=0) return 1;
	if (x-y<y) y=x-y;
	if (y==1) return x;
	ll re=1;
	fo(i,1,y)
	{
		//re=re*(x-y+i)/y;
		ll g=gcd(re,y),tp=(x-y+i);
		re/=g; y/=g; tp/=y;
		re*=tp;
		if (re%tp) return inf;
	}
	return re;
}
ll c1,c2,n,pp,re,sp;
bool check(ll mid)
{
	pp=0; re=0; ll up=mid/c2;
	ll last=-1;
	pp=0;ll calc=0;
	fd(l,up,0)
	{
		ll num=(mid-l*c2)/c1;
		if (l==0)
		{
			calc=1;
			pp+=calc;
			re+=calc*c1*(last+1);
			if (pp>=n) return 1;
			continue;
		}
		if (l==1 && sp)
		{
			pp+=max(num-last-1,0ll);
		} else
		{
			fd(j,num,last+2)
			{
				calc=c(j+l-1,l-1);
				pp+=calc;
				re+=calc*(l*c2+j*c1);
				if (pp>=n) return 1;
			}
		}
		calc=c(l+last+1,last+1);
		pp+=calc;
		re+=calc*(l*c2+(last+1)*c1);
		if (pp>=n) return 1;
		last=num;
	}
	return 0;
}
int main()
{
	//scanf("%I64d%I64d%I64d",&n,&c1,&c2);
	cin>>n>>c1>>c2;
	if (c1>c2) swap(c1,c2);
	if (c1==0)
	{
		cout<<c2*(n-1);
		return 0;
	}
	ll gp=gcd(c1,c2);
	c1/=gp; c2/=gp;
	ll l=0,r=10000000000000000ll,ans=0;
	sp=1;
	while (l<=r)
	{
		ll mid=(l+r)>>1;
		if (check(mid)) ans=mid,r=mid-1; else l=mid+1;
	}
	sp=0;
	pp=0;
	check(ans-1);
	ll rem=(n-pp);
	re=re+rem*((ans-c2)+c1+c2);
	cout<<re*gp;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<iostream>
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const ll inf=100000000000000000ll;
ll gcd(ll x,ll y)
{
	return y==0?x:gcd(y,x%y);
}
ll c(ll x,ll y)
{
	if (y<=0) return 1;
	if (x-y<y) y=x-y;
	if (y==1) return x;
	ll re=1;
	fo(i,1,y)
	{
		//re=re*(x-y+i)/y;
		ll g=gcd(re,y),tp=(x-y+i);
		re/=g; y/=g; tp/=y;
		re*=tp;
		if (re%tp) return inf;
	}
	return re;
}
ll c1,c2,n,pp,re,sp;
bool check(ll mid)
{
	pp=0; re=0; ll up=mid/c2;
	ll last=-1;
	pp=0;ll calc=0;
	fd(l,up,0)
	{
		ll num=(mid-l*c2)/c1;
		if (l==0)
		{
			calc=1;
			pp+=calc;
			re+=calc*c1*(last+1);
			if (pp>=n) return 1;
			continue;
		}
		if (l==1 && sp)
		{
			pp+=max(num-last-1,0ll);
			if (pp>=n) return 1;
		} else
		{
			fd(j,num,last+2)
			{
				calc=c(j+l-1,l-1);
				pp+=calc;
				re+=calc*(l*c2+j*c1);
				if (pp>=n) return 1;
			}
		}
		calc=c(l+last+1,last+1);
		pp+=calc;
		re+=calc*(l*c2+(last+1)*c1);
		if (pp>=n) return 1;
		last=num;
	}
	return 0;
}
int main()
{
	//scanf("%I64d%I64d%I64d",&n,&c1,&c2);
	cin>>n>>c1>>c2;
	if (c1>c2) swap(c1,c2);
	if (c1==0)
	{
		cout<<c2*(n-1);
		return 0;
	}
	ll gp=1;//gcd(c1,c2);
	c1/=gp; c2/=gp;
	ll l=0,r=10000000000000000ll,ans=0;
	sp=1;
	while (l<=r)
	{
		ll mid=(l+r)>>1;
		if (check(mid)) ans=mid,r=mid-1; else l=mid+1;
	}
	sp=0;
	pp=0;
	check(ans-1);
	ll rem=(n-pp);
	re=re+rem*((ans-c2)+c1+c2);
	cout<<re*gp;
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

const ll MXL = 0x3f3f3f3f3f3f3f3fLL;

ll lim = 50006;
ll n;
ll a, b;

vector<pair<ll,ll>> p; // {index, sum}
multiset<ll> s;

void ini() {
	p = {{0, 0}};
	s = {0};
	for (int i = 0; i < lim; ++i) {
		ll t = *s.begin();
		s.erase(s.begin());
		p.pb({t + b, -t + (t + a) + (t + b)});
		s.insert(t + a);
		s.insert(t + b);
	}
	ll pre = 0;
	for (auto &i : p)
		i.second = pre += i.second;
}

ll count(ll deep) {
	if (deep <= p.back().first)
		return upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)) - p.begin();
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		re += upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)) - p.begin();
		re = min(re, MXL);
	}
	return re;
}

ll sum(ll deep) {
	if (deep <= p.back().first)
		return prev(upper_bound(p.begin(), p.end(), make_pair(deep, LLONG_MAX)))->second;
	ll re = 0;
	for (auto i : s) if (i <= deep) {
		auto t = prev(upper_bound(p.begin(), p.end(), make_pair(deep - i, LLONG_MAX)));
		re += t->second + (t - p.begin()) * i;
		assert(re < MXL);
	}
	return re;
}

ll getDeep() {
	ll L = 0, R = MXL, M;
	while (L < R)
		if (M = L + R >> 1, count(M) >= n)
			R = M;
		else
			L = M + 1;
	return L;
}

int main() {
	cin >> n >> a >> b;
	if (a > b) swap(a, b);

	// 没判a,b为0的情况…wocao…

	if (a == 0 && b == 0) {
		cout << 0 << endl;
		return 0;
	}

	if (a == 0) {
		cout << (n - 1) * b << endl;
		return 0;
	}

	ini();

	ll h = getDeep();

	ll c = count(h);
	ll ans = sum(h);
	if (c > n)
		ans -= (c - n) * (h + (h - b + a) - (h - b));

	cout << ans << endl;

	return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }

long long nCr_saturated(long long n, long long k) {
	if(k > n) return 0;
	if(k > n / 2) k = n - k;
	if(k == 0) return 1;
	long long r = 1;
	for(int j = 1; j <= k; j ++) {
		ll a = n - k + j; int b = j;
		{
			int g = gcd((int)((n - k) % j), j);
			a /= g, b /= g;
		}
		r /= b;
		if(r * 1. * a > 2e18)
			return (long long)1e18 + 1;
		r *= a;
	}
	return min(r, (long long)1e18 + 1);
}

long long nCr(long long n, int k) {
	return nCr_saturated(n, k);
}

long long calcCount(long long bound, int c0, int c1) {
	assert(c0 <= c1);
	long long r = 0;
	for(int x = 0; (long long)x * c1 < bound; ++ x) {
		long long y = (bound - (long long)x * c1 - 1) / c0;
		//\sum_{i=0}^y C(x+i,x) = C(x+y+1,x+1)
		r += nCr(x + y + 1, x + 1);
		if(r > 1e18) return INFL;
	}
	return r;
}

long long calcSum(int x, long long y, int c0, int c1) {
	return (y + 1) * nCr(x + y + 1, x) * (c0 * y + c1 * (x + 2LL)) / (x + 2);
}

int main() {
	int n; int c0; int c1;
	while(~scanf("%d%d%d", &n, &c0, &c1)) {
		if(c0 > c1) swap(c0, c1);
		if(c0 == 0) {
			long long ans = (long long)c1 * (n - 1);
			printf("%lld\n", ans);
			continue;
		}
		long long lo = 0, up = 1;
		while(calcCount(up, c0, c1) < n - 1) up *= 2;
		while(up - lo > 0) {
			long long mid = (lo + up + 1) / 2;
			if(calcCount(mid, c0, c1) > n - 1)
				up = mid - 1;
			else
				lo = mid;
		}
		long long bound = up;
		long long ans = 0;
		for(int x = 0; (long long)x * c1 < bound; ++ x) {
			long long y = (bound - (long long)x * c1 - 1) / c0;
			ans += (c1 * x + c0 * (y + 1)) * nCr(x + y, x);
			//i >= (bound - c1 * (x + 1)) / c0
			long long iL = (bound - c1 * (x + 1) + c0 - 1) / c0;
			if(y < iL) continue;
			ans += calcSum(x, y, c0, c1);
			if(0 < iL) ans -= calcSum(x, iL - 1, c0, c1);
		}
		int rem = (int)((n - 1) - calcCount(bound, c0, c1));
		assert(rem >= 0);
		ans += rem * (bound + c0 + c1);
		printf("%lld\n", ans);
	}
	return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

long long nCr(long long n, int k) {
	if(k > n) return 0;
	if(k > n / 2) k = (int)(n - k);
	if(k == 0) return 1;
	long long r = 1;
	for(int j = 1; j <= k; j ++) {
		r *= n - k + j;
		r /= j;
	}
	return r;
}

long long calcCount(long long bound, int c0, int c1) {
	assert(c0 <= c1);
	long long r = 0;
	for(int x = 0; x * c1 < bound; ++ x) {
		long long y = (bound - x * c1 - 1) / c0;
		//\sum_{i=0}^y C(x+i,x) = C(x+y+1,x+1)
		r += nCr(x + y + 1, x + 1);
		if(r > 1e9) break;
	}
	return r;
}

long long calcSum(int x, long long y, int c0, int c1) {
	return (y + 1) * nCr(x + y + 1, x) * (c0 * y + c1 * (x + 2LL)) / (x + 2);
}

int main() {
	int n; int c0; int c1;
	while(~scanf("%d%d%d", &n, &c0, &c1)) {
		if(c0 > c1) swap(c0, c1);
		if(c0 == 0) {
			long long ans = (long long)c1 * (n - 1);
			printf("%lld\n", ans);
			continue;
		}
		long long lo = 0, up = 1;
		while(calcCount(up, c0, c1) < n - 1) up *= 2;
		while(up - lo > 0) {
			long long mid = (lo + up + 1) / 2;
			if(calcCount(mid, c0, c1) > n - 1)
				up = mid - 1;
			else
				lo = mid;
		}
		long long bound = up;
		long long ans = 0;
		for(int x = 0; x * c1 < bound; ++ x) {
			long long y = (bound - x * c1 - 1) / c0;
			ans += (c1 * x + c0 * (y + 1)) * nCr(x + y, x);
			//i >= (bound - c1 * (x + 1)) / c0
			long long iL = (bound - c1 * (x + 1) + c0 - 1) / c0;
			if(y < iL) continue;
			ans += calcSum(x, y, c0, c1);
			if(0 < iL) ans -= calcSum(x, iL - 1, c0, c1);
		}
		int rem = (int)((n - 1) - calcCount(bound, c0, c1));
		assert(rem >= 0);
		ans += rem * (bound + c0 + c1);
		printf("%lld\n", ans);
	}
	return 0;
}

#include <cstdio>
#include <algorithm>
#define inf 2147483647
using namespace std;
typedef long long ll;
ll c0,c1,n;
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
ll lls[31];
ll comb(ll a,ll b){
    ll s=1,x,g;
    for(ll i=0; ++i<=b; lls[i]=i);
    for(ll i=-1; ++i<b; ){
    	x=a+b-i;
    	for(ll j=0; ++j<=b; ){
    		g=gcd(lls[j],x);
    		x/=g;
    		lls[j]/=g;
		}
		if(x>inf/s)
			return inf;
		s*=x;
	}
    return s;
}
bool check(ll x){
	ll tmp=x/c0+x/c1+1;
	if(tmp>n)
    	return 1;
    for(ll i=0; ++i<=26; ){
		for(ll j=i-1; (++j)*c0+i*c1<=x; )
			if((tmp+=comb(j,i))>n)
				return 1;
		for(ll j=i; (++j)*c1+i*c0<=x; )
			if((tmp+=comb(j,i))>n)
				return 1;
	}
	return 0;
}
void work(ll x,ll &tmp,ll &ans){
	tmp=x/c0+x/c1+1;
	ans=((x/c0)*(x/c0+1)*c0+(x/c1)*(x/c1+1)*c1)>>1;
	ll c;
	for(int i=0; ++i<=26; ){
		for(ll j=i-1; (++j)*c0+i*c1<=x; ans+=c*(j*c0+i*c1))
			tmp+=(c=comb(j,i));
		for(ll j=i; (++j)*c1+i*c0<=x; ans+=c*(j*c0+i*c1))
			tmp+=(c=comb(j,i));
	}
}
int main(){
	scanf("%lld%lld%lld",&n,&c0,&c1);
	--n,c0>c1&&(swap(c0,c1),1);
	if(!c0){
		printf("%lld\n",n*c1);
		return 0;
	}
	ll l=0,r=c1*26,mid;
    while(l<=r){
        mid=(l+r)>>1;
        if(check(mid))r=mid-1;
        else l=mid+1;
    }
    ll c,s;
    work(l-1,c,s);
    s+=(n-c)*l+n*(c0+c1);
    printf("%lld\n",s);
    return 0;
}

#include <cstdio>
#include <algorithm>
#define inf 2147483647
using namespace std;
typedef long long ll;
ll c0,c1,n;
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
ll lls[31];
ll comb(ll a,int b){
    ll s=1,x,g;
    for(int i=0; ++i<=b; lls[i]=i);
    for(int i=-1; ++i<b; ){
    	x=a+b-i;
    	for(int j=0; ++j<=b; ){
    		g=gcd(lls[j],x);
    		x/=g;
    		lls[j]/=g;
		}
		if(x>inf/s)
			return inf;
		s*=x;
	}
    return s;
}
bool check(ll x){
	ll tmp=x/c0+x/c1+1;
	if(tmp>n)
    	return 1;
    for(int i=0; ++i<=26; ){
		for(ll j=i-1; (++j)*c0+i*c1<=x; )
			if((tmp+=comb(j,i))>n)
				return 1;
		for(ll j=i; (++j)*c1+i*c0<=x; )
			if((tmp+=comb(j,i))>n)
				return 1;
	}
	return 0;
}
void work(ll x,ll &tmp,ll &ans){
	tmp=x/c0+x/c1+1;
	ans=((x/c0)*(x/c0+1)*c0+(x/c1)*(x/c1+1)*c1)>>1;
	ll c;
	for(int i=0; ++i<=26; ){
		for(ll j=i-1; (++j)*c0+i*c1<=x; ans+=c*(j*c0+i*c1))
			tmp+=(c=comb(j,i));
		for(ll j=i; (++j)*c1+i*c0<=x; ans+=c*(j*c0+i*c1))
			tmp+=(c=comb(j,i));
	}
}

int main(){
	scanf("%lld%lld%lld",&n,&c0,&c1);
	--n,c0>c1&&(swap(c0,c1),1);
	if(!c0){
		printf("%lld\n",n*c1);
		return 0;
	}
	ll l=0,r=c1*26,mid;
    while(l<=r){
        mid=(l+r)>>1;
        if(check(mid))r=mid-1;
        else l=mid+1;
    }
    ll c,s;
    work(l-1,c,s);
    s+=(n-c)*l+n*(c0+c1);
    printf("%lld\n",s);
    return 0;
}

#ifndef LOCAL
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  for (auto it = d.b; it != d.e; ++it)
    *this << ", \0[" + 3 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};

#define imie(x) "[" << #x ": " << (x) << "] "

const int nax=100;
const int dax=50*1000;

int n;
long long c0, c1;

int roz[nax+2];
vector <int> wek[nax+2];
int gdz;

long long wyn;

int main()
{
	scanf("%d%lld%lld", &n, &c0, &c1);
	n--;
	if (c0>c1)
		swap(c0, c1);

	for (int i=1; i<=nax; i++)
		wek[i].resize(dax, 0);

	wyn=n*(c0+c1);
	while(n)
	{
		int bes=0;
		long long tam=c0*gdz;
		for (int i=1; wek[i][roz[i]]; i++)
		{
			if (i*c1+roz[i]*c0<tam)
			{
				tam=i*c1+roz[i]*c0;
				bes=i;
			}
		}
		wyn+=tam;
		if (!bes)
		{
			if (gdz<dax)
				wek[1][gdz]++;
			gdz++;
			n--;
		}
		else
		{
			int x=min(n, wek[bes][roz[bes]]);
			wek[bes][roz[bes]]=0;
			wek[bes][roz[bes]+1]+=x;
			wek[bes+1][roz[bes]]+=x;
			roz[bes]++;
			n-=x;
		}
	}

	printf("%lld\n", wyn);
	return 0;
}

//#ifndef LOCAL
//#define NDEBUG
//#endif

#include <bits/stdc++.h>
using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  for (auto it = d.b; it != d.e; ++it)
    *this << ", \0[" + 3 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};

#define imie(x) "[" << #x ": " << (x) << "] "

const int nax=100;
const int dax=50*1000;

int n;
long long c0, c1;

int roz[nax+2];
vector <int> wek[nax+2];
int gdz;

long long wyn;

int main()
{
	scanf("%d%lld%lld", &n, &c0, &c1);
	n--;
	if (c0>c1)
		swap(c0, c1);

	for (int i=1; i<=nax; i++)
		wek[i].resize(dax, 0);

	wyn=n*(c0+c1);
	while(n)
	{
		int bes=0;
		long long tam=c0*gdz;
		for (int i=1; wek[i][roz[i]]; i++)
		{
			if (i*c1+roz[i]*c0<tam)
			{
				tam=i*c1+roz[i]*c0;
				bes=i;
			}
		}
		wyn+=tam;
		if (!bes)
		{
			if (gdz<dax)
				wek[1][gdz]++;
			gdz++;
			n--;
		}
		else
		{
			int x=min(n, wek[bes][roz[bes]]);
			wek[bes][roz[bes]]=0;
			wek[bes][roz[bes]+1]+=x;
			wek[bes+1][roz[bes]]+=x;
			roz[bes]++;
			n-=x;
		}
	}
	for (int i=1; i<=nax; i++)
		assert(roz[i]<dax);
	printf("%lld\n", wyn);
	return 0;
}

#ifndef LOCAL
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  for (auto it = d.b; it != d.e; ++it)
    *this << ", \0[" + 3 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};

#define imie(x) "[" << #x ": " << (x) << "] "

const int nax=35;
const int dax=50*1000;

int n;
long long c0, c1;

int roz[nax+2];
vector <int> wek[nax+2];
int gdz;

long long wyn;

int main()
{
	scanf("%d%lld%lld", &n, &c0, &c1);
	n--;
	if (c0>c1)
		swap(c0, c1);

	for (int i=1; i<=nax; i++)
		wek[i].resize(dax, 0);

	wyn=n*(c0+c1);
	while(n)
	{
		int bes=0;
		long long tam=c0*gdz;
		for (int i=1; wek[i][roz[i]]; i++)
		{
			if (i*c1+roz[i]*c0<tam)
			{
				tam=i*c1+roz[i]*c0;
				bes=i;
			}
		}
		wyn+=tam;
		if (!bes)
		{
			if (gdz<dax)
				wek[1][gdz]++;
			gdz++;
			n--;
		}
		else
		{
			int x=min(n, wek[bes][roz[bes]]);
			wek[bes][roz[bes]]=0;
			wek[bes][roz[bes]+1]+=x;
			wek[bes+1][roz[bes]]+=x;
			roz[bes]++;
			n-=x;
		}
	}

	printf("%lld\n", wyn);
	return 0;
}

#ifndef LOCAL
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  for (auto it = d.b; it != d.e; ++it)
    *this << ", \0[" + 3 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};

#define imie(x) "[" << #x ": " << (x) << "] "

const int nax=35;
const int dax=150*100;

int n;
long long c0, c1;

int roz[nax+2];
vector <int> wek[nax+2];
int gdz;

long long wyn;

int main()
{
	scanf("%d%lld%lld", &n, &c0, &c1);
	n--;
	if (c0>c1)
		swap(c0, c1);

	for (int i=1; i<=nax; i++)
		wek[i].resize(dax, 0);

	wyn=n*(c0+c1);
	while(n)
	{
		int bes=0;
		long long tam=c0*gdz;
		for (int i=1; wek[i][roz[i]]; i++)
		{
			if (i*c1+roz[i]*c0<tam)
			{
				tam=i*c1+roz[i]*c0;
				bes=i;
			}
		}
		wyn+=tam;
		if (!bes)
		{
			if (gdz<dax)
				wek[1][gdz]++;
			gdz++;
			n--;
		}
		else
		{
			int x=min(n, wek[bes][roz[bes]]);
			wek[bes][roz[bes]]=0;
			wek[bes][roz[bes]+1]+=x;
			wek[bes+1][roz[bes]]+=x;
			roz[bes]++;
			n-=x;
		}
	}

	printf("%lld\n", wyn);
	return 0;
}

#ifndef LOCAL
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  for (auto it = d.b; it != d.e; ++it)
    *this << ", \0[" + 3 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};

#define imie(x) "[" << #x ": " << (x) << "] "

const int nax=100;
const int dax=50*1000;

int n;
long long c0, c1;

int roz[nax+2];
vector <int> wek[nax+2];
int gdz;

long long wyn;

int main()
{
	scanf("%d%lld%lld", &n, &c0, &c1);
	n--;
	if (c0>c1)
		swap(c0, c1);

	for (int i=1; i<=nax; i++)
		wek[i].resize(dax, 0);

	wyn=n*(c0+c1);
	while(n)
	{
		int bes=0;
		long long tam=c0*gdz;
		for (int i=1; wek[i][roz[i]]; i++)
		{
			if (i*c1+roz[i]*c0<tam)
			{
				tam=i*c1+roz[i]*c0;
				bes=i;
			}
		}
		wyn+=tam;
		if (!bes)
		{
			if (gdz<dax)
				wek[1][gdz]++;
			gdz++;
			n--;
		}
		else
		{
			int x=min(n, wek[bes][roz[bes]]);
			wek[bes][roz[bes]]=0;
			wek[bes][roz[bes]+1]+=x;
			wek[bes+1][roz[bes]]+=x;
			roz[bes]++;
			n-=x;
		}
	}
	for (int i=1; i<=nax; i++)
		assert(roz[i]<dax);
	printf("%lld\n", wyn);
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
#define CT printf("\n--------------------\n");
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
template<class _Tp>void ckmax(_Tp &a,_Tp b){if(a<b) a=b;}
template<class _Tp>void ckmin(_Tp &a,_Tp b){if(a>b) a=b;}
template<class _Tp>_Tp gcd(_Tp a,_Tp b){return (b==0)?(a):(gcd(b,a%b));}
int read(){
	char ch=getchar();bool f=1;int x=0;
	while((ch<'0' || ch>'9') && ch!='-') ch=getchar();
	if(ch=='-') f=0,ch=getchar();
	while(ch>='0' && ch<='9'){x=x*10+(ch&15);ch=getchar();}
	return f?x:-x;
}
const int inf=1000000000;
const ll Inf=1000000000000000000ll;
ll ans;
int n,a,b,s;
int c[20005];
bool check(ll m){
	int sum=m/a;
	for(int i=0;i<=s;++i)
		c[i]=i+1;
	for(int i=1;i*b<=m&&sum<n;++i)
		for(int j=0;i*b+j*a<=m&&sum<n;++j)
			sum+=c[j],c[j]+=(j?c[j-1]:0);
	return sum>=n;
}
void calc(ll m){
	int sum=m/a;
	ans+=sum*(sum+1)/2*a;
	for(int i=0;i<=s;++i)
		c[i]=i+1;
	for(int i=1;i*b<=m;++i)
		for(int j=0;i*b+j*a<=m;++j){
			ans+=c[j]*(i*b+j*a);
			sum+=c[j],c[j]+=(j?c[j-1]:0);
		}
	ans-=m*(sum-n);
}
int main(){
	n=read();a=read();b=read();
	if(a>b) swap(a,b);
	n--;
	ans=n*(a+b);
	n--;
	s=sqrt(n*2)+1;
	if(!a){
		printf("%lld\n",ans);
		return 0;
	}
	ll l=0,r=n*a;
	while(l<r){
		ll mid=(l+r)/2;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	calc(l);
	printf("%lld\n",ans);
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ans;
int n,a,b,s;
int c[20005];
bool check(ll m){
	int sum=m/a;
	for (int i=0;i<=s;i++) c[i]=i+1;
	for (int i=1;1ll*i*b<=m&&sum<n;i++)
		for (int j=0;1ll*i*b+1ll*j*a<=m&&sum<n;j++)
			sum+=c[j],c[j]+=(j?c[j-1]:0);
	return sum>=n;
}
void calc(ll m){
	int sum=m/a;
	ans+=1ll*sum*(sum+1)/2*a;
	for (int i=0;i<=s;i++) c[i]=i+1;
	for (int i=1;1ll*i*b<=m&&sum<n;i++)
		for (int j=0;1ll*i*b+1ll*j*a<=m&&sum<n;j++){
			ans+=1ll*c[j]*(1ll*i*b+1ll*j*a);
			sum+=c[j],c[j]+=(j?c[j-1]:0);
		}
	ans-=m*(sum-n);
}
int main(){
	scanf("%d%d%d",&n,&a,&b);
	if (a>b) swap(a,b);
	n--; ans=1ll*n*(a+b);
	n--; s=sqrt(n*2)+1;
	if (!a){
		printf("%lld\n",ans);
		return 0;
	}
	ll l=0,r=1ll*n*a;
	while (l<r){
		ll mid=(l+r)/2;
		if (check(mid)) r=mid;
		else l=mid+1;
	}
	calc(l);
	printf("%lld\n",ans);
}