Problem:
 Score : 200 points    Problem Statement Snuke has N integers. Among them, the smallest is A , and the largest is B .
We are interested in the sum of those N integers. How many different possible sums there are?      Constraints  1 ≤ N,A,B ≤ 10^9  A and B are integers.         Input Input is given from Standard Input in the following format:  N  A  B       Output Print the number of the different possible sums.        Sample Input 1 4 4 6      Sample Output 1 5  There are five possible sums: 18=4+4+4+6 , 19=4+4+5+6 , 20=4+5+5+6 , 21=4+5+6+6 and 22=4+6+6+6 .       Sample Input 2 5 4 3      Sample Output 2 0       Sample Input 3 1 7 10      Sample Output 3 0       Sample Input 4 1 3 3      Sample Output 4 1

Solution (Python):
n,a,b = list(map(int, input().split()))
ans = 0
if n==1 and a!=b:
    ans = 0
elif a>b:
    ans = 0
else:
    ans = ((n-1)*b + a) - ((n-1)*a + b) + 1
print(ans)

Solution (Python):
N, A, B = map(int, input().split())

if N == 1:
    if A == B:
        print(1)
    else:
        print(0)
elif A > B:
    print(0)
else:
    mini = A * (N - 1) + B
    maxi = B * (N - 1) + A
    ans = maxi - mini + 1
    print(ans)

Solution (Python):
N,A,B = list(map(int,input().split()))
if N==1 and A!=B:
    print(0)
    exit()
elif A>B:
    print(0)
    exit()

min = B+A*(N-1)
max = B*(N-1)+A
print(max-min+1)

Solution (Python):
N, A, B = map(int, input().split())
if A > B:
  print(0)
  exit()
if N == 1 and A != B:
  print(0)
  exit()
s1 = A * (N - 1) + B
s2 = B * (N - 1) + A
print(s2 - s1 + 1)

Solution (Python):
N,A,B=map(int,input().split())

m=A*(N-1)+B
M=A+B*(N-1)
ans=M-m+1
ans=max(ans,0)
print(ans)

Solution (Python):
n,a,b = [int(x) for x in input().split()]

if a > b:
    print(0)
elif n == 1:
    if a != b:
        print(0)
    else:
        print(1)
else:
    print((b-a)*(n-2)+1)

Solution (Python):
from itertools import product

n, a, b = map(int, input().split())

if a > b :
  print(0)
  exit()
elif n == 1:
  if a != b:
    print(0)
    exit()
  else:
    print(1)
    exit()
else:
  print((b-a) * (n-2) + 1)

Solution (Python):
n,a,b = map(int,input().split(' '))
minvalue = a*(n-1)+b
maxvalue = b*(n-1)+a
ans = (maxvalue-minvalue+1)
print(max(ans,0))

Solution (Python):
n , a , b = map(int,input().split())
if a > b:
    print(0)
    exit()
if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
else:
    print((b-a)*(n-2)+1)

Solution (Python):

N,A,B=map(int, raw_input().split())
if N==1:    
    if A!=B:    
        print 0
    else:
        print 1
else:   
    if B<A:
        print 0
    elif B==A:
        print 1  
    elif A<B:
        print A+B+B*(N-2)-(A+B+A*(N-2))+1

Solution (Python):
def examA():
    N, A, B = LI()
    if N==1:
        if A==B:
            print(1)
        else:
            print(0)
        return
    ans = (N-2)*max(B-A,0) + 1
    if B<A:
        ans = 0
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Solution (Python):
N,A,B = map(int,input().split())
if A > B:
    print(0)
    exit()
if N == 1:
    if A == B:
        print(1)
    else:
        print(0)
    exit()
print((B-A)*(N-2)+1)

Solution (Python):

import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') 
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(sys.stdin.readline()) 
def ifn(): return float(sys.stdin.readline()) 
def isn(): return sys.stdin.readline().split() 
def imn(): return map(int, sys.stdin.readline().split()) 
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) 
def fmn(): return map(float, sys.stdin.readline().split()) 
def iln(): return list(map(int, sys.stdin.readline().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, sys.stdin.readline().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,A,B = imn()

min_v = A+B+((N-2)*A)
max_v = A+B+((N-2)*B)
print(max(0, max_v-min_v+1))

Solution (Python):
n,a,b=map(int,input().split())

if (n==1 and a!=b) or a>b:
  print(0)
  exit()
  
print((b-a)*(n-2)+1)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, a, b = map(int, readline().split())
if a > b:
    print(0)
elif n == 1:
    if a != b:
        print(0)
    else:
        print(1)
else:
    print(a + b * (n - 1) - (b + a * (n - 1)) + 1)

Solution (Python):
N, A, B = map(int, input().split())

if A > B:
    print(0)
elif N == 1 and A != B:
    print(0)
elif N == 1 and A == B:
    print(1)
elif N == 2 and A != B:
    print(1)
else:
    min_tmp = A*(N-1) + B
    max_tmp = B*(N-1) + A
    print(max_tmp-min_tmp+1)

Solution (Python):
n,a,b= list(map(int, input().split()))
if a>b:
    print("0")
    exit(0)
if n==1:
    if a!=b:
        print("0")
    else:
        print("1")
    exit(0)
n-=2;b-=a;a=0
print(b*n+1)

Solution (Python):
n,a,b=map(int,input().split())
if n==1 and a!=b:
    print(0)
    exit()
if a>b:
    print(0)
    exit()

mi=(n-1)*a + b
ma=(n-1)*b + a
print(ma-mi+1)

Solution (Python):
n, a, b = map(int, input().split())

if b < a:
    print(0)
elif n == 1:
    if a == b:
        print(1)
    else:
        print(0)
else:
    small = a * (n - 2)
    big = b * (n - 2)
    num = big - small + 1
    print(num)

Solution (Python):
n,a,b=map(int,input().split())
print(max(0,(n-2)*(b-a)+1))

Solution (Python):
N, A, B = map(int, input().split())

ans = max(0, (A + B * (N - 1)) - (A * (N - 1) + B) + 1)
print(ans)

Solution (Python):
import sys

n,a,b = map(int,input().split())

if n == 1:
    if a != b:
        print(0)
        exit()

if a > b:
    print(0)
    exit()
    
print(-(a*(n-1)+b)+(a+b*(n-1))+1)

Solution (Python):
N, A, B = map(int, input().split())
maxi = A + B*(N-1)
mini = A*(N-1) + B
print(max(0, maxi-mini+1))

Solution (Python):
n,a,b  = map(int,input().split())
if a > b:ans = 0
elif n == 1:
    if a == b:ans = 1
    else:ans = 0
else:
    ans = (b-a)*(n-2)+1
print(ans)

Solution (Python):
N, A, B = map(int, input().split())
if A > B:
    ans = 0
elif N == 1:
    if A==B:
        ans = 1
    else:
        ans = 0
else:
    ans = (N-2)*(B-A)+1
print(ans)

Solution (Python):
n, a, b = map(int, input().split())
if a > b:
    print(0)
elif n == 1:
    if a != b:
        print(0)
    else:
        print(1)
else:
    print((a+b+b*(n-2)) - (a+b+a*(n-2)) + 1)

Solution (Python):
n,a,b = map(int,input().split())
if a>b:
    print(0)
else:
    if n==1:
        if a==b:
            print(1)
        else:
            print(0)
    else:
        mn = (n-1)*a+b
        mx = a+(n-1)*b
        print(mx-mn+1)

Solution (Python):
import math

N, A, B = map(int, input().split())
if A > B: print(0)
elif N == 1:
    if A == B: print(1)
    else: print(0)
else: print((B-A)*(N-2)+1)

Solution (Python):
N, A, B = map(int, input().split())
if A > B:
    print(0)
    exit()
if N == 1:
    print(0 if A != B else 1)
    exit()

print((B-A)*(N-2) + 1)

Solution (Python):
N, A, B = map(int, input().split())

if A > B:
    print(0)
elif N == 1:
    if A == B:
        print(1)
    else:
        print(0)
elif N == 2:
    print(1)
else:
    temp = (N - 2) * (B - A) + 1
    print(temp)

Solution (Python):
N,A,B = map(int,input().split())

B_max = B*(N-1)+A
A_min = A*(N-1)+B

if A>B:
  print(0)
elif A==B:
  print(1)
elif N==1:
  print(0)
else:
  print(B_max-A_min+1)

Solution (Python):
N, MIN, MAX = map(int, input().split())

sum_min = (N-1)*MIN + MAX
sum_max = (N-1)*MAX + MIN



if N > 1:
    if sum_max >= sum_min:
        print(sum_max - sum_min + 1)
    else:
        print(0)
elif N == 1:
    if MIN!= MAX:
        print(0)
    else:
        print(1)

Solution (Python):
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)


n,a,b = map(int,input().split())
low = b + a*(n-1)
high = a + b*(n-1)
print(max(0,high - low +1))

Solution (Python):
n,a,b=map(int,input().split())
if b<a:
    print(0)
else:
    if n==1 and a!=b:
        print(0)
    else:
        min_=(n-2)*a
        max_=(n-2)*b
        print(max_-min_+1)

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,a,b = m()

if a > b:
    print(0)
elif n == 1:
    if a == b:
        print(1)
    else:
        print(0)
else:
    print((n-1)*b + a - (b + (n-1)*a) + 1)

Solution (Python):
N,A,B = list(map(int, input().split()))


print(max((N-2)*B-(N-2)*A+1,0))

Solution (Python):
n,a,b = map(int,input().split())
if n == 1 and a != b or b-a <= -1:
  print(0)
elif n == 2:
  print(1)
else:
  min_ans = a*(n-1)+b
  max_ans = b*(n-1)+a
  ans = max_ans - min_ans + 1
  print(ans)

Solution (Python):
N,A,B = map(int, input().split())


if A>B:
  print(0)
elif (N==1 and A!=B):
  print(0)
elif (N==1 and A==B):
    print(1)
else:
  print((B-A)*(N-2)+1)

Solution (Python):
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)


inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""


def main():
    N, A, B = map(int, input().split())
    a = A*(N-1)+B
    b = B*(N-1)+A
    if b-a+1 >= 0:
        print(b-a+1)
    else:
        print(0)


if __name__ == '__main__':
    main()

Solution (Python):
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)


inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""


def main():
    N, A, B = map(int, input().split())
    a = A*(N-1)+B
    b = B*(N-1)+A
    if b-a+1 >= 0:
        print(b-a+1)
    else:
        print(0)


if __name__ == '__main__':
    main()

Solution (Python):
n,a,b=list(map(int,input().split()))
print(max((b*(n-1)+a)-(a*(n-1)+b)+1,0))

Solution (Python):
N, A, B = map(int, input().split())
if N == 1:
    if A == B: print(1)
    else:print(0)
    exit()
if A > B:
    print(0)
    exit()
m = A + (N-2)*A + B
M = A + (N-2)*B + B
print(max(0,M-m+1))

Solution (Python):
n,a,b = map(int, input().split())
if n == 1:
  if a != b:
    print(0)
  else:
    print(1)
elif n == 2:
  if a == b or a < b:
    print(1)
  else:
    print(0)
else:
  if  a > b:
    print(0)
  else:
    print((b - a) * (n - 2) + 1)

Solution (Python):
n, a, b = map(int, input().split())
if a>b or n==1 and a!=b:
    print(0)
else:
    print((b*(n-1)+a)-(a*(n-1)+b)+1)

Solution (Python):
n, a, b = map(int, input().split())

if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
    exit()

if n == 2:
    if a > b:
        print(0)
    else:
        print(1)
    exit()

if a > b:
    print(0)
    exit()

ans = (n - 2) * (b - a) + 1
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()
if A > B or N == 1 and A != B:
	print(0)
	exit()
mi = A*(N-1)+B
ma = A+B*(N-1)
print(ma-mi+1)

Solution (Python):
n, a, b = map(int, input().split())
if a == b:
    ans = 1
elif n >= 2:
    ans = max(0, (n - 2) * (b - a) + 1)
else:
    ans = 0
print(ans)

Solution (Python):
n,a,b=map(int,input().split())
mi=(a*(n-1))+b
ma=(b*(n-1))+a

if ma-mi<0:
    print("0")
else:
    print((ma-mi+1))

Solution (Python):
n, a, b = map(int, input().split())
if n == 1:
    print(1 if a == b else 0)
else:
    print((b-a)*(n-2)+1 if a <= b else 0)

Solution (Python):
N,a,b=map(int, input().split())
if a>b:
  print(0)
elif a<b and N==1:
  print(0)
else:
  print(b*(N-2)-a*(N-2)+1)

Solution (Python):
n, a, b = map(int, input().split())

def check():
    if a > b:
        return 0
    elif a != b and n == 1:
        return 0
    elif n <= 2:
        return 1

    else:
        ba = b - a
        return 1 + ba * (n - 2)

print(check())

Solution (Python):
n,a,b=map(int,input().split())
print(max((n-2)*(b-a)+1,0))

Solution (Python):

from collections import Counter
def inputlist(): return [int(j) for j in input().split()]

N,A,B = inputlist()
if A>B:
    print(0)
    exit()
ans = (B-A)*(N-2) +1
if ans <=0:
    ans = 0
print(ans)

Solution (Python):
N, A, B = map(int, input().split())

if A > B:
    print(0)
elif A == B:
    print(1)
else:
    if N == 1:
        print(0)
    else:
        print((N - 2)*(B - A) + 1)

Solution (Python):
N, A, B = map(int, input().split())

if (A > B):
    print(0)
elif (N == 1):
    print(int(A == B))
else:
    print((N - 2) * (B - A) + 1)

Solution (Python):
N, A, B = map(int,input().split())
ans = (A+(B*(N-1)))-(B+(A*(N-1)))+1
if ans < 0:
    ans =0
print(ans)

Solution (Python):
N, A, B = map(int, input().split())

if N == 1 and A != B :
    print(0)
    exit()
if A > B :
    print(0)
    exit()

smin = (N-1)*A + B
smax = A + (N-1)*B
print(smax-smin+1)

Solution (Python):
N, A, B = map(int, input().split())
mi = A + B + A*(N-2)
ma = A + B + B*(N-2)
print(max(0,ma-mi+1))

Solution (Python):
n,a,b = map(int,input().split())

ans = 0
if n==0 or (n==1 and a!=b) or (a>b):
  pass
elif (n==1) and (a==b):
  ans = 1
else:
  ans = (n-2)*(b-a)+1
  
print(ans)

Solution (Python):
import sys


while True:
    try:
        line = sys.stdin.readline().strip()
        if line == "":
            break
        nums = list(map(int, line.split()))
        N, A, B = nums[0:3]

        if N <= 0 or A > B or (A < B and N == 1):
            print(0)
            continue
        if(A == B or (A < B and N == 2)):
            print(1)
            continue
        print(B * (N - 2) - A * (N - 2) + 1)

    except:
        break

Solution (Python):
N,A,B = map(int, input().split())
ret = 0
if A <= B:
    ret = max((B*(N-1)+A) - ((N-1)*A+B) + 1, 0)

print(ret)

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False



def main():
    N, A, B = MI()

    if A > B:
        print(0)
        return

    if A != B and N == 1:
        print(0)
        return

    min_v = A * (N - 1) + B
    max_v = A + B * (N - 1)
    print(max_v - min_v + 1)


if __name__ == '__main__':
    main()

Solution (Python):
n,a,b = map(int,input().split())

if a == b:
    print (1)
    exit ()

if a >= b or n < b - a:
    print (0)
    exit ()

print ((b-a)*(n-2)+1)

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    if A > B:
        print(0)
        return
    
    if N == 1:
        if A==B:
            print(1)
        else:
            print(0)
        return
    
    min_sum = A*(N-1)+B
    max_sum = A+B*(N-1)
    print(max_sum-min_sum+1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(N, A, B)

if __name__ == '__main__':
    main()

Solution (Python):
n, a, b = map(int, input().split())

if a > b:
    print(0)
elif n == 1:
    if a == b:
        print(1)
    else:
        print(0)
else:
    print((n - 2) * b - (n - 2) * a + 1)

Solution (Python):

N, A, B = map(int, input().split(' '))

if A > B:
    print(0)

elif N == 1:
    if A != B:
        print(0)
    else:
        print(1)

else:
    min_n = A * (N - 1) + B
    max_n = A + (N - 1) * B
    print(max_n - min_n + 1)

Solution (Python):
def main():
    length, min_number, max_number = map(int, input().split())
    print(max(0, (length - 2) * (max_number - min_number) + 1) if min_number <= max_number else 0)


if __name__ == '__main__':
    main()

Solution (Python):
n,a,b=map(int,input().split())
if n>1 and b>=a or n==1 and a==b: 
    print ((n-2)*(b-a)+1);
else:
    print ("0");

Solution (Python):
n, a, b = map(int, input().split())

ans = 0
if n == 1:
    if a == b:
        ans = 1
    else:
        ans = 0
else:
    if a > b:
        ans = 0
    else:
        ans =  (a + b *(n - 1)) - (a * (n - 1) + b) + 1
print(ans)

Solution (Python):
n, a, b = map(int, input().split())

mn = a * (n - 1) + b
mx = a + b * (n - 1)
ans = max(0, mx - mn + 1)

print(ans)

Solution (Python):
n,a,b=map(int,input().split())
print(max(0,(b-a)*(n-2)+1))

Solution (Python):
N,A,B=map(int,input().split())
MIN=A*(N-1)+B
MAX=B*(N-1)+A
ans=MAX-MIN+1
print(ans if ans>=0 else 0)

Solution (Python):
n, A, B = map(int, input().split())
if A > B:
  print(0)
elif n == 1:
  if A != B:
    print(0)
  else:
    print(1)
else:
  print((B - A) * (n - 2) + 1)

Solution (Python):
N,A,B = map(int, input().split())

"""
MIN: (N - 1) * A + B
MAX: A + (N - 1) * B

MAX - MIN + 1
= (N - 1) * (B - A) - (B - A) + 1
= (N - 2) * (B - A) + 1
"""

if N == 1 and A != B:
    print(0)
elif A > B:
    print(0)
else:
    print((B - A) * (N - 2) + 1)

Solution (Python):
N,A,B = map(int, input().split())

if N == 1 and A != B:
    print(0)
elif A > B:
    print(0)
else:
    print(abs(B - A) * abs(N - 2) + 1)

Solution (Python):
import sys

input = sys.stdin.buffer.readline







def main():
	n,a,b=map(int,input().split())
	if b<a:
		print(0)
	else:
		print(max(0,(b-a)*(n-2)+1))


if __name__ == "__main__":
	main()

Solution (Python):
if __name__ == "__main__":
    n, a, b = list(map(int, input().split()))

    ans = 0

    if b >= a and n > 2:
        ans = (n - 2) * b - (n - 2) * a + 1
    elif n == 1 and a == b:
        ans = 1
    elif n == 2 and b >= a:
        ans = 1

    print(ans)

Solution (Python):
N, A, B = map(int,input().split())
if N == 1:
    print(1 if A==B else 0)
else:
    if A > B:
        print(0)
    else:
        m = A*(N-1)+B
        M = B*(N-1)+A
        print(M-m+1)

Solution (Python):
n, a, b = map(int, input().split())
if a>b: ans = 0
elif n==1:
        if a==b: ans = 1
        else: ans = 0
else: ans = (b-a)*(n-2)+1
print(ans)

Solution (Python):
n,a,b=map(int,input().split())
if n==1:
    if a==b:
        print(1)
        exit()
    else:
        print(0)
        exit()
if a>b:
    print(0)
    exit()
mini=a+b+(n-2)*a
maxi=a+b+(n-2)*b
print(maxi-mini+1)

Solution (Python):
N,A,B = map(int,input().split())

if A > B :
  print(0)
elif N == 1 and A == B:
  print(1)
elif N == 1 and A!= B:
  print(0)
else:
  a = (N-2)*(B-A) + 1
  print(a)

Solution (Python):
n, a, b = map(int, input().split())
ans = max(0, b * (n - 1) + a - (b + a * (n - 1)) + 1)
print(ans)

Solution (Python):
def main():
    N, A, B = (int(i) for i in input().split())
    if (N == 1 and A != B) or (B - A < 0):
        print(0)
    elif N == 1:
        print(1)
    else:
        print((N-2)*B - (N-2)*A + 1)


if __name__ == '__main__':
    main()

Solution (Python):

n, a, b = map(int,input().split())

if b < a:
    print(0)
elif n == 1 and a != b:
    print(0)
else:
    ans = ((n - 1) * b + a) - ((n - 1) * a + b) + 1 
    print(ans)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n, a, b = MAP()
if b < a:
    print(0)
    exit()
if a == b and n == 1:
    print(1)
    exit()
if a != b and n == 1:
    print(0)
    exit()
if n == 2:
    print(1)
    exit()
if b - a - 1 <= 0:
    print(1)
    exit()
print(a + (n - 1) * b - (n - 1) * a - b + 1)

Solution (Python):
n,a,b = map(int,input().split())
if n == 1 and a == b:
    print(1)
elif (n == 1 and a != b) or a > b:
    print(0)
else:
    print((n-1)*b+a-((n-1)*a+b)+1)

Solution (Python):
n,a,b=map(int,input().split())
res=(b*(n-1)+a)-(a*(n-1)+b)+1
print(max(0,res))

Solution (Python):
def main():
    N, A, B = (int(i) for i in input().split())
    if (N == 1 and A != B) or (B - A < 0):
        print(0)
    elif N == 1:
        print(1)
    elif N == 2:
        print(1)
    else:
        print((N-2)*B - (N-2)*A + 1)


if __name__ == '__main__':
    main()

Solution (Python):
N, A, B = map(int, input().split())

high = (N - 1) * B + A
low = (N - 1) * A + B
ans = high - low + 1
ans = max(0, ans)

print(ans)

Solution (Python):
N,A,B = map(int, input().split())

if N == 1 and A != B:
    print(0)
    exit()
if A > B:
    print(0)
    exit()
if N == 2:
    print(1)
    exit()

m = N - 2
print(B*m - A*m + 1)

Solution (Python):
import sys
stdin = sys.stdin
mod = 10**9 + 7

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))


n, a, b = na()
sum_min = a * (n-1) + b
sum_max = a + (n-1) * b

if n == 0 and a != b:
    print(0)
else:
    print(max(0, sum_max - sum_min + 1))

Solution (Python):
n,a,b=map(int,input().split())
if n==1:
  if a!=b:print(0);exit()
if a>b:print(0);exit()
mi=a*(n-1)+b
ma=a+b*(n-1)
print(ma-mi+1)

Solution (Python):
n, a, b = map(int, input().split())
if n == 1:
    if a != b:
        print(0)
        exit()
    else:
        print(1)
        exit()

min_  = a + a*(n-2) + b
max_ = a + b*(n-2) + b

print(max(0, max_-min_+1))

Solution (Python):
N,A,B = map(int,input().split())
m = A*(N-1) + B
M = B*(N-1) + A
ans = M-m+1
if A > B:
    print(0)
    exit()
if A != B and N == 1:
    print(0)
    exit()

print(ans)

Solution (Python):
N, A, B = map(int, input().split())
mn = (N-1)*A+B
mx = A+(N-1)*B
print(max(0, mx-mn+1))

Solution (Python):
p,n,m=map(int,input().split())
if p==1:print(int(m==n))
elif n>m:print(0)
else:print((m-n)*(p-2)+1)

Solution (Python):
N,A,B = map(int,input().split())

if N==0:
    print(0)
elif N==1 and A==B:
    print(1)
elif N==1 and A!=B:
    print(0)
elif A>B:
    print(0)
elif N>=2:
    mx = B*(N-1)+A
    mn = A*(N-1)+B
    print(mx-mn+1)

Solution (Python):
N, A, B = map(int, input().split())
if A > B :
    print(0)
elif N == 1 :
    print(0 if A != B else 1)
else :
    print((B - A) * (N - 2) + 1)

Solution (Python):
def main():
    N, A, B = map(int, input().split())
    if N == 1 and A != B:
        print(0)
        return
    if A > B:
        print(0)
        return
    min_sum = A * (N - 1) + B
    max_sum = A + (N - 1) * B
    ans = max_sum - min_sum + 1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):

n,a,b = map(int,input().split())

if n == 1:
    if a == b:
        print(1)
    elif a != b:
        print(0)
else:
    if a > b:
        print(0)
    else:
        print((n-2)*(b-a)+1)

Solution (Python):
n,a,b=map(int,input().split())
if n==1:
  if a==b:
    print(1)
  else:
    print(0)
  exit()
if a>b:
  print(0)
  exit()
print((n-2)*(b-a)+1)

Solution (Python):
n,a,b = map(int,input().split())

print(max(0,(n-1)*b + a - ((n-1)*a + b) + 1))

Solution (Python):
def main():
    n, a, b = map(int, input().split())
    ans = (b*(n-1)+a) - (a*(n-1)+b) + 1
    if a > b or (n == 1 and a != b):
        print("0")
    else:
        print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
N, A, B = map(int, input().split())

if N == 1:
    if A == B:
        print(1)
    else:
        print(0)
    exit()

if A > B:
    print(0)
    exit()


ans = B * (N - 2) - A * (N - 2) + 1
print(ans)

Solution (Python):
n,a,b=map(int,input().split())
now=(n-1)*b+a-(n-1)*a-b+1
A=[0,now]
print(max(A))

Solution (Python):
N, A, B = map(int, input().split())
ans = (B - A) * (N - 2) + 1
if A > B or (A != B and N <= 1):
    print(0)
else:
    print(ans)

Solution (Python):
import itertools

N, A, B = list(map(int,input().split()))

if N==1:
    if A==B:
        print(1)
        exit()
    else:
        print(0)
        exit()

if A > B:
    print(0)
    exit()

min = A*(N-1)+B
max = A+B*(N-1)

print(max-min+1)

Solution (Python):
N,A,B=map(int,input().split())
if (A<B)and(N>1):
 print((B-A)*(N-2)+1)
elif (A==B):
 print("1")
else:
 print("0")

Solution (Python):
n, a, b = map(int, input().split())
import itertools

if a > b:
  print(0)
  exit()

if n == 1:
  if a != b:
    print(0)
  else:
    print(1)
  exit()
  
print((b-a)*(n-2)+1)

Solution (Python):
n, a, b = map(int, input().split())

if (n == 1 and a < b) or a > b:
    print(0)
elif n == 2:
    print(1)
else:
    print(b*(n - 1) + a - a*(n - 1) - b + 1)

Solution (Python):
n,a,b=map(int,input().split())
if a>b:
  print(0)
  exit()
if a==b:
  print(1)
  exit()
if n==1:
  print(0)
  exit()
minimum = a*(n-1)+b
maximum = b*(n-1)+a
if n<=2:
  print(1)
else:
  print(maximum-minimum+1)

Solution (Python):
n,a,b=map(int,input().split())
if a>b or (n==1 and a!=b):
    print(0)
elif a==b:
    print(1)
else:
    print((b-a)*(n-2)+1)

Solution (Python):
N, A, B = map(int, input().split())

m = A * (N - 1) + B
M = B * (N - 1) + A

print(max(0, M - m + 1))

Solution (Python):
n,a,b = map(int, input().split())
if a > b:
    print(0)
elif a==b:
    print(1)
elif n == 1 and a!=b:
    print(0)
elif n == 1:
    print(1)
elif n == 2:
    print(1)
else:
    c1 = a * n + (b-a)
    c2 = b * n - (b-a)
    print(c2-c1 + 1)

Solution (Python):
n,a,b=map(int,input().split())
if a<b:
    if n>3:
    	print((b-a)*(n-2)+1)
    if n==2:
    	print(1)
    if n==1:
      	print(0)
    
elif a==b:
    print(1)
elif a>b:
    print(0)

Solution (Python):
n,a,b=map(int,input().split())
print(max(0,(n-2)*(b-a)+1))

Solution (Python):
N,A,B=map(int, input().split())
if N==1:
    print(int(A==B))
elif A>B:
    print(0)
else:
    print((N-2)*(B-A)+1)

Solution (Python):
N,A,B=map(int,input().split())
ans=0
if A>B or (N==1 and A!=B):
    ans=0
elif N==1 and A==B:
    ans=1
else:
    ans=(N-2)*(B-A)+1
print(ans)

Solution (Python):
N,A,B=map(int,input().split())
M=B*(N-1)+A
m=A*(N-1)+B
if M>=m:
  print(M-m+1)
else:
  print(0)