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

Solution (Python):
import sys

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

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

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

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

Solution (Python):
import sys

input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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


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

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

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

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

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

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

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

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

Solution (Python):

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

Solution (Python):


import math

import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd


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

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

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

if N < 1 or B - A < 0:
  print(0)
  exit(0)
  
if N == 1 and A < B:
  print(0)
  exit(0)
  
  
if A == B or N <= 2:
  print(1)
  exit(0)
  
c = N-2
r = B-A+1

ans = c*(r-1) + 1
print(ans)

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

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

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

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

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

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

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

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 = map(int,input().split())

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

ans = maximum-minimum+1

if a > b or (n == 1 and a != b):
    print(0)
else:
    print(ans)

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

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

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

nin=A*(N-1)+B
nax=A+B*(N-1)

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

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

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

x = B*(N-1)+A
n = A*(N-1)+B
print(x-n+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()
elif n == 1 and a == b:
    print(1)
    exit()

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

Solution (Python):

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

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

Solution (Python):
import sys, math
from functools import lru_cache
import numpy as np
import heapq
from collections import defaultdict
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


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


def main():
    N, A, B = mi()
    if A > B or (N == 1 and A != B):
        print(0)
        return

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

if __name__ == '__main__':
    main()

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

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

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

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

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

n-=2

if n<0:
  print(0)
  exit()

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

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

Solution (Python):

import sys



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


def input_int():
    return int(input())


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


def main():
    n, a, b = input_int_list()
    if b < a or (n == 1 and a != b):
        print(0)
        sys.exit()
    n -= 2
    if n == 0:
        print(1)
    else:
        ans = (b * n) - (a * n) + 1
        print(ans)

    return


if __name__ == "__main__":
    main()

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

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

minans = a*(n-1)+b
maxans = a+b*(n-1)

if a>b or (n==1 and a!=b):
    print(0)
else:
    print(maxans-minans+1)

Solution (Python):
a = [int(s) for s in input().split()]
if a[1] > a[2]:
    print("0")
elif a[1] == a[2]:
    print("1")
elif a[0] == 1:
    print("0")
else:
    mini = a[2] + a[1] * (a[0] - 1)
    maxi = a[1] + a[2] * (a[0] - 1)
    print(int(maxi) - int(mini) + 1)

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,a,b = LI()
    ans = 0
    if n == 1:
        if a == b:
            ans = 1
        else:
            ans = 0
    elif n == 2:
        if a <= b:
            ans = 1
        else:
            ans = 0
    else:
        if a <= b:
            summin = a*(n-1) + b
            summax = a + b*(n-1)
            ans = summax - summin + 1
        else:
            ans = 0

    print(ans)
        
main()

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

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
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 functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

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


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

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

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

Solution (Python):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,a,b = I()

if (n == 1) and (a == b):
    print(1)
    sys.exit()

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

if (n == 2) or (a == b):
    print(1)
    sys.exit()

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




"""
n = k()
s = v()

def check(n):
    if 


comand = ["A","B","X","Y"]
p = list(itertools.permutations(comand,2))
for i in range(len(p)):
    p[i] = "".join(p[i])

for i in 
"""

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 n == 1 and a != b:
    ans = 0
elif b < a:
    ans = 0
else:
    ans = (b * (n - 1) + a) - (a * (n - 1) + b) + 1

print(ans)

Solution (Python):
import sys
import 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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()

if A > B:
    ans = 0
elif N == 1 and A < B:
    ans = 0
else:
    ans = (N - 2) * (B - A) + 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
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
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 = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()
b = N - 2
mi = A * b
ma = B * b
print(max(ma - mi + 1, 0))

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

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

Solution (Python):
N,A,B=list(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=[int(i) for i in input().split()]
if b<a 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 A>B or N==1 and A!=B :print(0)
else: print((N-2)*(B-A)+1)

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

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

print(max(0, ma - mi + 1))

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

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

print(ans)

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

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

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

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

print(ans)

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

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

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

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

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

  print(ans)

main()

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

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

  if ans < 0:
    ans = 0
  else:
    ans += 1

  print(ans)

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

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

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

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

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

if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
else:
    if a > b:
        print(0)
    else:
        mins = (n-1)*a + b
        maxs = a + (n-1)*b
        print(maxs - mins + 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:
    number=B-A+1
    N=N-2
    answer=N*(B-A)+1
    print(answer)

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys
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())

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

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

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

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

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

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

Solution (Python):
N,A,B = [int(i) for i in input().split()]

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

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

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

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

if __name__ == "__main__":
    main()

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

Solution (Python):
import math
import sys
import bisect
readline = sys.stdin.readline


def main():
    n, a, b = map(int, readline().rstrip().split())
    if n == 1:
        print(1 if a == b else 0)
        return
    if a > b:
        print(0)
        return

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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
N, A, B = [int(_) for _ in input().split()]

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

Solution (Python):









import os
import sys




def main():
    n, a, b = map(int, input().split())
    down = (n-1)*a + b
    up = (n-1)*b + a
    if up-down+1 > 0:
        print(up-down+1)
    else:
        print(0)


if __name__ == "__main__":
    main()

Solution (Python):
N,A,B = [int(i) for i in input().split()]
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);exit()
if n==1 and a!=b:print(0);exit()
print((b-a)*(n-2)+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()
print((b-a)*(n-2)+1)

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

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

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

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

Solution (Python):
n,Min,Max = map(int,input().split())
sum_min = Min * (n-1) + Max
sum_max = Max * (n-1) + Min
ans = sum_max - sum_min + 1
print(max(0,ans))

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

def main():
    n, a, b = map(int, input().split())
    if (a > b) or (n==1 and a<b):
        print(0)
    elif n == 1 and a == b:
        print(1)
    else:
        print(n*(b-a)+2*(a-b)+1)
            
if __name__ == '__main__':
    main()

Solution (Python):

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

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

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

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

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

print(M - m + 1)

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

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

min_v=a*(n-1)+b
max_v=b*(n-1)+a

print(max(0,max_v-min_v+1))

Solution (Python):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,a,b=nii()

min_v=a*(n-1)+b
max_v=b*(n-1)+a

print(max(0,max_v-min_v+1))

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

Solution (Python):
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B = mapint()

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, a, b = map(int, readline().split())
    ans = max(b * (n - 2) - a * (n - 2) + 1, 0)
    print(ans)


if __name__ == '__main__':
    main()

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

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

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

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

if (A < B and N > 1) or (A==B):
  minimum_sum = A*(N-1) + B
  maximum_sum = A + B*(N-1)
  print(maximum_sum - minimum_sum + 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):
import sys
input = sys.stdin.readline

N,A,B = list(map(int,input().split()))
min_sum = A*(N-1)+B
max_sum = B*(N-1)+A
print(max(0,max_sum-min_sum+1))

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial





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

t = 1

for case in range(1,t+1):
    ans = solve()


"""



"""

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

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

Solution (Python):


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

Solution (Python):
if __name__ == '__main__':
    n,a,b = map(int, input().split())
    minN = a+ b+ (n-2)*a
    maxN = a+ b+ (n-2)*b
    calc = max(maxN-minN+1,0)
    print(calc)

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

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

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


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

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

Solution (Python):

import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n, a, b = LI()

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

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

Solution (Python):
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

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