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):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,a,b = readInts()
if a > b:
    print(0)
else:
    if n == 1:
        if a != b:
            print(0)
        else:
            print(1)
    elif a == b:
        print(1)
    else:
        print((b * (n-1) + a) - ((a*(n-1)) + b) + 1)

Solution (Python):
import sys

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

mi = A * (N-1) + B
ma = A + B * (N-1)

if ma - mi + 1 < 0:
  print(0)
  sys.exit()

print(ma - mi + 1)

Solution (Python):






import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
n,a,b=MI()
if a>b:
    print(0)
    sys.exit()
if a!=b and n<2:
    print(0)
    sys.exit()
mx=b*(n-1)+a
mn=a*(n-1)+b
print(mx-mn+1)

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, A, B = inm()


def solve():
    if A > B:
        return 0
    if N == 1:
        return 0 if A != B else 1
    a = A * (N - 1) + B
    b = B * (N - 1) + A
    return b - a + 1


print(solve())

Solution (Python):
n, a, b = map(int, input().split())
if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
elif b < a:
    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)
elif b < a:
    print(0)
else:
    print(b*(n-1)+a-a*(n-1)-b+1)

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
N, A, B = map(int, input().split())
print(max(0, (N - 1) * B + A - ((N - 1) * A + B) + 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 N < 2:
    if A == B:
        print(1)
    else:
        print(0)
elif A <= B:
    ans = range((A+B) + A*(N-2), (A+B) + B*(N-2) + 1)
    print(len(ans))
else:
    print(0)

Solution (Python):






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





if N < 2:
    if A == B:
        print(1)
    else:
        print(0)
elif A <= B:
    ans = range((A+B) + A*(N-2), (A+B) + B*(N-2) + 1)
    print(len(ans))
else:
    print(0)

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

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

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

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

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

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

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

Solution (Python):
n, a, b = [int(x) for x in input().split()]
val = max(0, (a + (n - 1) * b) - ((n - 1) * a + b) + 1)
print(val)

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def main():
	
	n, a, b = tin()
	
	if n == 1 and a != b:
		return 0
		
	if n == 1:
		return 1
		
	if a > b:
		return 0
	
	max_v = b * (n-1) + a
	min_v = b + a *(n-1)
	return max_v - min_v + 1


	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

Solution (Python):
n, a, b = map(int, input().split())
if b < a or (a != b and n == 1):
    print(0)
    exit()
if a == b:
    print(1)
    exit()
_min = a*(n-1)+b
_max = a+b*(n-1)
ans = _max - _min + 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(A+B*(N-1)-(N-1)*A-B+1)

Solution (Python):
N,A,B = map(int,input().split())
if N == 1:
    if A != B:
        print(0)
    else:
        print(1)
elif A == B:
    print(1)
elif 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 A > B:
    print(0)
elif A == B:
    print(1)
else:
    if N == 1:
        print(0)
    else:
        minimum = A*(N-1)+B
        maximum = B*(N-1)+A
        print(maximum-minimum+1)

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

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

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

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

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

n = N-2 
C = 0 

if (N == 1 and A != B) or B < A:
    C = 0
else:
    C = (B*n-A*n)+1
print(int(C))

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

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

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


ans=0
if n==1 and a!=b:
    ans=0
elif a==b:
    ans=1
elif a>b:
    ans=0
else:
    s_a = a*(n-1) + b
    s_b = a + b*(n-1)

    ans= s_b - s_a + 1

print(ans)

Solution (Python):
N, A, B = [int(x) for x in input().split()]
ans = max(0, (A + (N - 1) * B) - ((N - 1) * A + B) + 1)
print(ans)

Solution (Python):
import math

import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)

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

    return

if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, A, B = map(int, read().split())

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

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

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

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

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

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


if __name__ == '__main__':
    resolve()

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:
    ans = (N-2)*(B-A) + 1
    print(ans)

Solution (Python):



from fractions import gcd














import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())

n,a,b = readInts()
if n == 1 and not a == b:
    print(0)
elif a == b:
    print(1)
elif a > b:
    print(0)
else:
    wa = a+b
    m = wa + b*(n-2)
    i = wa + a*(n-2)
    print(m-i+1)

Solution (Python):
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, a, b = map(int, input().split())
if a > b:
    print(0)
    exit()
if n == 1 and not(a == b):
    print(0)
    exit()
if n == 1 and(a == b):
    print(1)
    exit()
max_x = b*(n-1)+a
min_x = a*(n-1)+b
print(max_x-min_x+1)

Solution (Python):
N,A,B = map(int,input().split())
if A>B:
    ans = 0
elif 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())
Min, Max = a*(n-1)+b, b*(n-1)+a
print(Max-Min+1 if Max-Min+1>0 else 0)

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

Solution (Python):
import sys
input = sys.stdin.readline
from collections import *

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

if A>B:
    print(0)
    exit()
    
m = B+A*(N-1)
M = A+B*(N-1)
print(max(0, M-m+1))

Solution (Python):
def main():
    N, A, B = map(int, input().split())
    if A > B:
        return 0
    if N == 1:
        if A != B:
            return 0
        else:
            return 1
    if N == 2:
        return 1

    mn = A * (N - 1) + B
    mx = A + B * (N - 1)
    return mx - mn + 1


if __name__ == "__main__":
    print(main())

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

Solution (Python):
N, A, B = map(int, input().split())
print(max(0, B*(N-2) - A*(N-2)  +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:
    print(1)
else:
    print(A+B*(N-1)-(A*(N-1)+B)+1)

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

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


if n==1 and a!=b:
    print(0)
    exit()
elif n==1 and a==b:
    print(1)
    exit()
elif a>b:
    print(0)
    exit()
elif a==b:
    print(1)
    exit()
m=a*(n-2)
M=b*(n-2)
ans=M-m+1
print(ans)

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

Solution (Python):
def main():
    N, A, B = map(int, input().split())
    ans = 0

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

    print(ans)
    
if __name__ == "__main__":
    main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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
from decimal import *

N, A, B = MAP()

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

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

print(MAX - MIN + 1)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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
from decimal import *

N, A, B = MAP()

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

if MAX < MIN:
	print(0)
	exit()

print(MAX - MIN + 1)

Solution (Python):



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

if __name__ == '__main__':
    main()

Solution (Python):
n,a,b=map(int,input().split())
ans=b*(n-1)+a-a*(n-1)-b+1
if ans<=0:
  print(0)
else:
  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 = (b-a)*(n-2)+1

print(ans)

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

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

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

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')
AtoZ = "abcdefghijklmnopqrstuvwxyz"






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N,A,B = IL()
if A <= B:
  if N != 1:
    print((A+B*(N-1))-(B+A*(N-1))+1)
  else:
    if A==B:
      print(1)
    else:
      print(0)
else:
  print(0)

Solution (Python):
N,A,B=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())
ans=(A+B*(N-1))-(A*(N-1)+B)+1
print(ans if ans>=0 else 0)

Solution (Python):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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

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


if __name__ == '__main__':
    main()

Solution (Python):

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

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

Solution (Python):
N, A, B = map(int, input().split())
print(0 if N == 1 and A != B else max(0, max(0, N - 2) * (B - A) + 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:
    print(1)
elif n==2:
    print(1)
else:
    if a==b:
        print(1)
    else:
        n-=2
        print((b-a)*n+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:
    
    print(1 + (b - a) * (n - 2))

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

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

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, A, B = [int(x) for x in input().split()]

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

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

    

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, a, b = list(map(int, input().split()))
    if (n == 1 and a != b) or (b < a):
        print(0)
        exit()
    mini = a * (n - 1) + b
    maxi = a + b * (n - 1)
    print(maxi - mini + 1)


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    N, A, B = [int(x) for x in input().strip().split()]
    if N == 1 and A != B:
        print(0)
        return
    elif A > B:
        print(0)
        return
    print((B * (N - 1) + A) - (B + A * (N - 1)) + 1)

if __name__ == '__main__':
    main()

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

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

if N == 1:
    if diff != 0:
        print(0)
    else:
        print(1)
else:
    if diff < 0:
        print(0)
    elif diff == 0:
        print(1)
    else:
        max_val = B * (N-1) + A
        min_val = A * (N-1) + B
        print(max_val - min_val + 1)

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

x = b*(a-1)+c
y = c*(a-1)+b

print(max(0,y-x+1))

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

Solution (Python):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction



mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]









n,A,B=l()

mnn=A*(n-1)+B
mxx=A+B*(n-1)
print(max(mxx-mnn+1,0))

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

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

    print(max_sum - min_sum + 1)

Solution (Python):
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,A,B = LI()
if A>B:
    print(0)
    exit()
if N==1:
    print(1 if A==B else 0)
    exit()
print((N-2)*(B-A)+1)

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

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

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):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    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)
    elif n == 2:
        print(1)
    else:
        print((b-a)*(n-2)+1)

if __name__ == '__main__':
    main()

Solution (Python):
N, A, B = map(int, input().split())
max_value = (N - 1) * B + A
min_value = (N - 1) * A + B

if max_value >= min_value:
    print(max_value - min_value + 1)
else:
    print(0)

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

if a > b:
    ans = 0
elif a != b and n == 1:
    ans = 0

print(ans)

Solution (Python):
n,a,b=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())
mx = a+(n-1)*b
mn = b+(n-1)*a
print(max(0, mx-mn+1))

Solution (Python):
import itertools

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

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

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

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

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

Solution (Python):
import sys

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

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

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

Solution (Python):
import sys

N, A, B = map(int, sys.stdin.readline().strip().split())

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

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

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

ans = 0
if n >= 2 and a <= b:
    lst_min = a * (n - 1) + b
    lst_max = a + b * (n - 1)
    
    ans = lst_max - lst_min + 1

elif n == 1 and a == b:
    ans = 1

print(ans)

Solution (Python):



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

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

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

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

Solution (Python):
import fractions
import sys
from functools import reduce
import math

input = sys.stdin.readline


def main():
    n, a, b = input_list()
    if a > b:
        print(0)
        exit(0)
    if n == 1 and a != b:
        print(0)
        exit(0)
    if n == 1 and a == b:
        print(1)
        exit(0)
    min_num = (a*(n-1))+b
    max_num = (b*(n-1))+a
    print(max_num-min_num+1)


def get_camulative(l):
    import itertools
    
    return [0] + list(itertools.accumulate(l))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()

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

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

Solution (Python):
import itertools

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

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

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

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

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

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

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

ans_min = B + A * (N - 1)
ans_max = B * (N - 1) + A

ans = max(0, ans_max - ans_min + 1)

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
from collections import *

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

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

if N==1 and A!=B:
    print(0)
    exit()
    
low = A+B+(N-2)*A
high = A+B+(N-2)*B
print(high-low+1)

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