Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. Winnie has got three best friends: Rabbit, Owl and Eeyore, each of them lives in his own house. There are winding paths between each pair of houses. The length of a path between Rabbit's and Owl's houses is a meters, between Rabbit's and Eeyore's house is b meters, between Owl's and Eeyore's house is c meters.

For enjoying his life and singing merry songs Winnie-the-Pooh should have a meal n times a day. Now he is in the Rabbit's house and has a meal for the first time. Each time when in the friend's house where Winnie is now the supply of honey is about to end, Winnie leaves that house. If Winnie has not had a meal the required amount of times, he comes out from the house and goes to someone else of his two friends. For this he chooses one of two adjacent paths, arrives to the house on the other end and visits his friend. You may assume that when Winnie is eating in one of his friend's house, the supply of honey in other friend's houses recover (most probably, they go to the supply store).

Winnie-the-Pooh does not like physical activity. He wants to have a meal n times, traveling minimum possible distance. Help him to find this distance.


-----Input-----

First line contains an integer n (1 ≤ n ≤ 100) — number of visits.

Second line contains an integer a (1 ≤ a ≤ 100) — distance between Rabbit's and Owl's houses.

Third line contains an integer b (1 ≤ b ≤ 100) — distance between Rabbit's and Eeyore's houses.

Fourth line contains an integer c (1 ≤ c ≤ 100) — distance between Owl's and Eeyore's houses.


-----Output-----

Output one number — minimum distance in meters Winnie must go through to have a meal n times.


-----Examples-----
Input
3
2
3
1

Output
3

Input
1
2
3
5

Output
0



-----Note-----

In the first test case the optimal path for Winnie is the following: first have a meal in Rabbit's house, then in Owl's house, then in Eeyore's house. Thus he will pass the distance 2 + 1 = 3.

In the second test case Winnie has a meal in Rabbit's house and that is for him. So he doesn't have to walk anywhere at all.

Difficulty: interview

Starter code:

Solutions:
'''input
1
2
3
5
'''
n = int(input())
a = int(input())
b = int(input())
c = int(input())
cur = 0
pos = 0
for i in range(n-1):
    if pos == 0:
        if a < b:
            pos = 1
            cur += a
        else:
            pos = 2
            cur += b 
    elif pos == 1:
        if a < c: 
            pos = 1
            cur += a
        else:
            pos = 3
            cur += c
    else:
        if b < c: 
            pos = 2
            cur += b
        else:
            pos = 3
            cur += c                     
print(cur)            

n = int(input())
a = int(input())
b = int(input())
c = int(input())

if n == 1:
    print(0)
else:
    print(min([a*(n-1), b*(n-1), c*(n-2)+a, c*(n-2)+b]))

n=int(input())
a=int(input())
b=int(input())
c=int(input())
if a==min(a,b,c):
    print(a*(n-1))
elif b==min(a,b,c):
    print(b*(n-1))
else:
    if n==1:
        print(0)
    elif n==2:
        print(min(a,b))
    else:
        print(min(a,b)+(n-2)*c)


n, a, b, c = [int(input()) for i in range(4)]
if n == 1:
    print(0);
else:
    print(min(a * (n - 1), b * (n - 1), min(a, b) + c * (n - 2)))

n = int(input()) - 1
a = int(input())
b = int(input())
c = int(input())
result = 0
cur = 'k'
while n > 0:
    if cur == 'k':
        if a < b:
            cur = 's'
            result += a
        else:
            cur = 'i'
            result += b
    elif cur == 's':
        if a < c:
            cur = 'k'
            result += a
        else:
            cur = 'i'
            result += c
    else:
        if b < c:
            cur = 'k'
            result += b
        else:
            cur = 's'
            result += c
    n -= 1
print(result)


n=int(input())
a=int(input())
b=int(input())
c=int(input())
x=0
if n>1:
    x=min(a,b)
    if n>2:
        x+=min(x,c)*(n-2)
print(x)


n = int(input())
a = int(input())
b = int(input())
c = int(input())

house = 'rab'
answer = 0

for i in range(n - 1):
    if house == 'rab':
        if a < b:
            house = 'owl'
            answer += a
        else:
            house = 'eey'
            answer += b
    elif house == 'owl':
        if a < c:
            house = 'rab'
            answer += a
        else:
            house = 'eey'
            answer += c
    else:
        if b < c:
            house = 'rab'
            answer += b
        else:
            house = 'owl'
            answer += c

print(answer)


import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [I() for _ in range(3)]
    r = 0
    if n == 1:
        return 0
    r += min(a[0],a[1])
    if n > 1:
        r += min(a) * (n-2)

    return r


print(main())




n = int(input())
a = int(input())
b = int(input())
c = int(input())
ans = 0
t = 0
n-=1
if n == 0:
    print(0)
    return
if c < a and c < b:
    ans = min(a, b) + (n-1)*c
else:
    ans = min(a, b)*(n)
print(ans)

n = int(input())
a = int(input())
b = int(input())
c = int(input())
if n == 1:
    print(0)
else:
    ans = min(a, b)
    n -= 2
    if a <= b:
        ans = ans + n * min(a, c)
    else:
        ans = ans + n * min(b, c)
    print(ans)
    



n=int(input())
a=int(input())
b=int(input())
c=int(input())

if n==1:
	print(0)
	return

x=min(a,b,c)
if x in [a,b]:
	print((n-1)*x)
else:
	print(min(a,b)+(n-2)*c)


n = int(input()) - 1
a = int(input())
b = int(input())
c = int(input())
if n == 0:
    print(0)
else:
    minimum = min(a, b, c)
    print((n-1)*minimum + min(a, b))


read = lambda: tuple(map(int, input().split()))
n, a, b, c = read()[0], read()[0], read()[0], read()[0]
n -= 1
if n == 0:
    print(0)
elif n == 1:
    print(min(a, b))
else:
    print(min(a + c * (n - 1), b + c * (n - 1), b * n, a * n))


n=int(input())
a = int(input())
b = int(input())
c = int(input())

n-=1
t = 0
if n>0:
	t+=min([a,b])
	n-=1
t+=min([a,b,c])*n
print(t)

n=int(input())
a=int(input())
b=int(input())
c=int(input())
if(n==1):
  print(0)
else:
  dist=[a,b,c]
  dist.sort()
  min1=dist[0]
  min2=dist[1]
  min3=dist[2]
  if(min1==a or min1==b):
    print((n-1)*min1)
  else:
    print(min2+((n-2)*min1))

n = int(input())
a = int(input())
b = int(input())
c = int(input())

dist = 0
curr = 'r'
while n > 1:
  n -= 1
  if curr == 'e':
    if b < c:
      curr = 'r'
      dist += b
    else:
      curr = 'o'
      dist += c
  elif curr == 'o':
    if a < c:
      curr = 'r'
      dist += a
    else:
      curr = 'e'
      dist += c
  else:
    if a < b:
      curr = 'o'
      dist += a
    else:
      curr = 'e'
      dist += b
print(dist)

n = int(input())
a = int(input())
b = int(input())
c = int(input())

ans = 0

if n == 1:
	pass
elif n == 2:
	ans += min(a, b)
else:
	if c < a and c < b:
		ans += min(a, b) + (n - 2) * c
	else:
		ans += (n - 1) * min(a, b)

print(ans)

n=int(input())
a=int(input())
b=int(input())
c=int(input())
if n==1:
    print(0)
else:
    mi=min(a,b,c)
    if mi==a:
        dist=a*(n-1)
    elif mi==b:
        dist=b*(n-1)
    elif mi==c:
        ma=min(a,b)
        if ma==a:
            dist=a
        else:
            dist=b
        dist=dist+c*(n-2)
    print(dist)
        


n = int(input())
a = int(input())
b = int(input())
c = int(input())

count = 1
length = 0

x = 1

while count < n:
    count += 1
    if x == 1:
        if a < b:
            x = 2
            length += a
        else:
            x = 3
            length += b
    elif x == 2:
        if a < c:
            x = 1
            length += a
        else:
            x = 3
            length += c
    else:
        if b < c:
            x = 1
            length += b
        else:
            x = 2
            length += c
print(length)

def __starting_point():
    N = int(input())
    A = int(input())
    B = int(input())
    C = int(input())
    cnt = 0
    result = 1145141919
    res1 = A * (N - 1)
    res2 = B * (N - 1)
    if (N >= 2):
        res3 = min(A, B) + C * (N - 2)
        result = min(result, res3)
    result = min(result, res1, res2)
    print (result)

__starting_point()

n = int(input()) - 1
a = int(input())
b = int(input())
c = int(input())
print(max(min(n * a, n * b, (n - 1) * c + min(a, b)), 0))


import copy

def solve():
    
    n, a, b, c = [int(input()) for i in range(4)]

    nowloc = 'ab'
    mealed = 1
    totaldistance = 0
    history = ['ab']

    while mealed < n:
        
        if nowloc == 'ab':
            if a < b:
                nowloc = 'ac'
                totaldistance += a
            else:
                nowloc = 'bc'
                totaldistance += b

        elif nowloc == 'bc':
            if b < c:
                nowloc = 'ab'
                totaldistance += b
            else:
                nowloc = 'ac'
                totaldistance += c

        elif nowloc == 'ac':
            if a < c:
                nowloc = 'ab'
                totaldistance += a
            else:
                nowloc = 'bc'
                totaldistance += c

        history.append(copy.deepcopy(nowloc))
        mealed += 1

    return totaldistance, history

print(solve()[0])


n = int(input())
a = int(input())
b = int(input())
c = int(input())
if n == 1:
    print(0)
elif c == min(a, b, c):
    print(min(a, b) + (n-2)*c)
else:
    print((n-1) * min(a, b))
    



#python3
#utf-8

visits_nr = int(input())
ro_dist = int(input())
rd_dist = int(input())
od_dist = int(input())
# pref_end_r___min_dist
# pref_end_o___min_dist
# pref_end_d___min_dist
pref_end_r___min_dist = [0] * visits_nr
pref_end_o___min_dist = [10**9] * visits_nr
pref_end_d___min_dist = [10**9] * visits_nr
for visit in range(1, visits_nr):
    pref_end_r___min_dist[visit] = min(pref_end_o___min_dist[visit - 1] + ro_dist, pref_end_d___min_dist[visit - 1] + rd_dist)
    pref_end_o___min_dist[visit] = min(pref_end_r___min_dist[visit - 1] + ro_dist, pref_end_d___min_dist[visit - 1] + od_dist)
    pref_end_d___min_dist[visit] = min(pref_end_o___min_dist[visit - 1] + od_dist, pref_end_r___min_dist[visit - 1] + rd_dist)
ans = min((pref_end_d___min_dist[-1], pref_end_o___min_dist[-1], pref_end_r___min_dist[-1]))
print(ans)