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):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]


def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,a,b = get_nums_l()

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

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

if n == 2:
    print(1)
    exit()

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

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

Solution (Python):
n, a, b = list(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((n-2)*(b-a) + 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)
else:
    print((N-2)*(B-A)+1)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

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

print(ans)

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

if __name__ == '__main__':
    main()

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-a)*(n-2)+1)

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

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

print(max((n-2)*(b-a)+1,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:
    mx = a + b * (n - 1)
    mn = a * (n - 1) + b
    print(mx-mn+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:
    print((B-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)
else:
    minimum = a * (n-1) + b
    maximum = a + (n-1) * b
    print(maximum - minimum + 1)

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

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

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

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

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

print(ans)

Solution (Python):

def pin(type=int):
    return map(type,input().split())

"""
方針
O(1)
"""


N,A,B=pin()
if A==B:
    print(1)
elif A>B or 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 and a != b:
  print(0)
elif n == 1 and a == b:
  print(1)
else:
  print((b*(n-1)+a) - (a*(n-1)+b) + 1)

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

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

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

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

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

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

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

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

Solution (Python):
import sys
 
stdin = sys.stdin

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, a, b = na()

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

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

Solution (Python):
import sys
input = sys.stdin.buffer.readline

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

if __name__ == "__main__":
    main()

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

Solution (Python):
'''
制約
1≦N,A,B≦10^9
N  = 1の時ABもない

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

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

    ans = max_sum - min_sum + 1

    print(ans)

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

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


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

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

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

min_s = a*(n-1) + b
max_s = b*(n-1) + a

print(max(max_s - min_s + 1, 0))

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

if A > B or (N == 1 and A != B):
    print(0)
else:
    lower = (N - 1) * A + B
    upper = (N - 1) * B + A
    print(upper - lower + 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()
least=(N-1)*A+B
most=A+(N-1)*B
print(most-least+1)

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

c = a*(n-1) + b
d = a + b*(n-1)

print(max(d-c+1, 0))

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

if n == 1:
    if a == b:
        ans = 1
    else:
        ans = 0
else:
    if a > b:
        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 and b>=a or n==1 and a==b: 
    print ((n-2)*(b-a)+1);
else:
    print ("0");

Solution (Python):
from sys import stdin
n,a,b = [int(x) for x in stdin.readline().rstrip().split()]

saisyou = a*(n-1)+b
saidai = b*(n-1)+a

if n == 1 and a!= b:
    print(0)
    exit()
elif a > b:
    print(0)
    exit()
else:
    print(saidai-saisyou+1)

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

Solution (Python):

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

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


if __name__ == '__main__':
    main()

Solution (Python):

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

Solution (Python):
import sys

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

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

maximum = (a+b) + b*(n-2)
minimum = (a+b) + a*(n-2)

print(maximum-minimum+1)

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

Min=A*(N-2)+A+B
Max=B*(N-2)+A+B

if Max-Min+1<1:
    print(0)
else:
    print(Max-Min+1)

Solution (Python):

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

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

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

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

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

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

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

print(ans)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10


def solve():
    n, a, b = LI()
    print(max(b * n + a - b - (a * n - a + b - 1),0))
    return



if __name__ == '__main__':
    solve()

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

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

if ans < 0:
    print(0)
else:
    print(ans)

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

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

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

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:
    answer = 0
elif N == 1:
    if A != B:
        answer = 0
    else:
        answer = 1
else:
    x = A * (N-1) + B
    y = A + B * (N-1)
    answer = y - x + 1

print(answer)

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

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())
print(max(0,((b-a)*(n-2)+1)))

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

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

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

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

Solution (Python):
import sys
import os
if sys.platform=="darwin":
   base = os.path.dirname(os.path.abspath(__file__))
   name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
   
   sys.stdin = open(name)

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

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

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

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

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

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

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

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())
minn = A * (N - 1) + B
maxn = B * (N - 1) + A
if minn > maxn:
    print(0)
elif minn == maxn:
    print(1)
else:
    print(maxn - minn + 1)

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

if a > b:
    print(0)
elif a == b:
    print(1)
elif a < b and n == 1:
    print(0)
elif a < b and n == 2:
    print(1)
elif (a < b) and n >= 3:
    print((b-a)*(n-2)+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 <= 2:
    ans = 1
else:
    mn = A * (N-1) + B
    mx = A + B * (N-1)
    ans = mx - mn + 1
print(ans)

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

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    if A > B :
        print(0)
    
    elif N == 1 and A == B:
        print(1)
    
    elif N == 1 and A < B:
        print(0)

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

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

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

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

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

Solution (Python):
import numpy as np
import scipy as sp

def main():
    
    N, A, B = parse(get_stdin())
    
    result = compute(N, A, B)
    
    print(result)

def compute(N, A, B):
    if N == 0:
        return 0
    if N == 1:
        if A == B:
            return 1
        else:
            return 0
    if A > B:
        return 0
    x = B - A
    n = N - 2
    return x * n + 1

def get_stdin():
    return input()

def split_stdin(stdin_val, delimiter = ' '):
    return [x for x in stdin_val.split(delimiter) if x != '']

def parse(stdin_vars):
    vars = split_stdin(stdin_vars)
    return int(vars[0]), int(vars[1]), int(vars[2])

if __name__ == "__main__":
    main()

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

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

max_sum = a + b*(n-1)
min_sum = b + a*(n-1)

print(max(max_sum - min_sum + 1,0))

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

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

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

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

maxi=(N-1)*B + A
mini=(N-1)*A + B

ans = maxi - mini +1

print(max(ans,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 b>a:
        num_min = (n-2)*a+a+b
        num_max = (n-2)*b+a+b
        ans = num_max-num_min+1
    elif b<a:
        ans=0
    elif a==b:
        ans=1
print(ans)

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

if x <= 0:
    print(0)
else:
    print(x)

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

if (n == 1 and a != b) or a > b:
    ans = 0
else:
    min_num = b + (a * (n - 1))
    max_num = a + (b * (n - 1))
    ans = max_num - min_num + 1

print(ans)

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

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

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

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

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

Solution (Python):

import sys


def main():
    n, a, b = [int(x) for x in sys.stdin.readline().split()]


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

if __name__ == '__main__':
    main()

Solution (Python):

import sys


def main():
    n, a, b = [int(x) for x in sys.stdin.readline().split()]

    min_possible = a * (n - 1) + b
    max_possible = b * (n - 1) + a

    ans = max_possible - min_possible + 1
    print(max(ans, 0))

if __name__ == '__main__':
    main()

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

if a > b:
    print(0)
    exit()
    
if n == 0:
    print(0)
    eixt()
    
if n == 1:
    if a == b:
        print(1)
        exit()
    else:
        print(0)
        exit()
        
n_s = n - 2
s = b-a

ans = (b-a)*n_s + 1

print(ans)

Solution (Python):

from itertools import combinations_with_replacement

n, a, b = [int(s) for s in input().split()]


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

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

m = a*(n-1) + b
M = a + b*(n-1)

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

Solution (Python):
from sys import stdin
N, A, B = [int(_) for _ in stdin.readline().rstrip().split()]
if A > B:
    print(0)
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())
print(max((b*(n-1)+a)-(a*(n-1)+b)+1,0))

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

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

print(max-min + 1)

Solution (Python):
from operator import mul
from functools import reduce


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


def cmb(n, r):
    
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, A, B = inpl()

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



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

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

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

Solution (Python):

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

    if n == 0:
        ans=0
        print(ans)
        return
    elif n==1:
        if a==b:
            ans=1
            print(ans)
            return
        else:
            ans=0
            print(ans)
            return

    elif n>=2:
        ans=1
        if a>b:
            ans=0
            print(ans)
            return

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




if __name__ == '__main__':
    main()

Solution (Python):
N, A, B = map(int, input().split())
if A > B:
    print(0)
    exit()
if N == 1:
    print(int(A==B))
    exit()
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)
    exit()

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

Solution (Python):
def calc():
    n, a, b = map(int, input().split())
    if a > b:
        return 0
    if n == 1 and a < b:
        return 0

    upper = a + b * (n - 1)
    lower = b + a * (n - 1)
    return upper - lower + 1


print(calc())

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

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

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

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

if n == 1 and  a != b :
    print(0)
    exit()
print((a + b * (n - 1)) - (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)

else:
    temp1=A+B+A*(N-2)
    temp2=A+B+B*(N-2)
    print(max(temp2-temp1+1,0))

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

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

Solution (Python):


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

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

print(ans)

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

ans = (b-a) * (n-2) + 1
if ans < 0:
    ans = 0
print(ans)

Solution (Python):
def accumulate(a, b):
    k = b - a + 1
    return k * (k+1) // 2 + k * (a-1)

def solve(n, a, b):
    if b < a:
        return 0
    if n == 1:
        if a == b:
            return 1
        else:
            return 0
    else:
        return (b - a) * (n - 2) + 1

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

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

if(B-A<0):
    print("0")
    exit()
if(A==B):
    print("1")
    exit()

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

if(N==2):
    print("1")
    exit()

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

Solution (Python):
n, a, b = [int(i) for i in input().split()]
if a > b:
    print(0)
elif a != b and n == 1:
    print(0)
else:
    c = a * (n - 1) + b
    d = a + b * (n - 1)
    print(d-c+1)

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

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

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

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

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

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

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

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

if A > B:
  print(0)
elif A == B:
  print(1)
else:
  if 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())
print(max((2-n)*a+(n-2)*b+1,0))

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

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

if N == 1 or A == B:
    print(1)
    exit()

minS = A * (N - 1) + B
maxS = A + B * (N - 1)

print(maxS - minS + 1)

Solution (Python):

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

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

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, a, b = list(map(int, input().rstrip('\n').split()))
    if a > b:
        print(0)
    elif a == b:
        print(1)
    elif n - 2 < 0:
        print(0)
    else:
        c = n - 2
        print(abs(a * c - b * c) + 1)


if __name__ == '__main__':
    slove()

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

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


if __name__ == "__main__":
    resolve()

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

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):
import sys
input=sys.stdin.readline

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

if __name__ == '__main__':
    main()

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:
    sum_max=A+B+(N-2)*B
    sum_min=A+B+(N-2)*A
    print(sum_max-sum_min+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:
        print((b-a)*(n-2)+1)

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

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

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

min_val = (N - 1) * A + B
max_val = (N - 1) * B + A
print(max_val - min_val + 1)

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

if N==1 and A!=B : print(0)
elif N==1 and A==B : print(1)
elif 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())

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

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

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

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

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

digit = N - 1
min_calc = A*digit + B
max_calc = A + B*digit
ans = max_calc - min_calc + 1
print(ans)

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