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 = list(map(int,input().split()))
M = (N[2] - N[1]) * (N[0] - 2) + 1
if N[0] == 1 and N[1] == N[2]:
    print(1)
elif N[0] == 1:
    print(0)
elif N[0] == 2:
    print(1)
elif N[1] > N[2]:
    print(0)
else:
    print(M)

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

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

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

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

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

if max_num - min_num + 1 >= 0:
    print(max_num - min_num + 1)
else:
    print(0)

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


def read():
    N, A, B = map(int, input().strip().split())
    return N, A, B


def solve(N, A, B):
    low = (N-1) * A + B - 1
    high = A + (N-1) * B
    return max(high - low, 0)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

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

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

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

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

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

if __name__ == "__main__":
    main()

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,A,B=MI()
    N-=1
    print(max(0,B*N+A-(A*N+B)+1))
if __name__ == '__main__':
    main()

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 N == 0 or A > B:
    print(0)
    quit()
if N == 1 and A != B:
    print(0)
    quit()
minSum = A * (N-1) + B
maxSum = A + B * (N-1)
print(maxSum-minSum+1)

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

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

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

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

min_sum = 0

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

am = N - 2

minv = A + B + am*A

maxv = A + B + am*B
print(maxv - minv + 1)

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

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

if max_sum - min_sum >= 0:
    print(max_sum - min_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)
    exit()
m = a * (n - 1) + b
M = a + b * (n - 1)
print(M - m + 1)

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

Solution (Python):
def answer(n, a, b):
    if (a > b): return 0
    if n == 1 and a != b: return 0
    n = n-2
    small = a*n
    big = b*n
    return big - small + 1

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

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

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

print(ans if ans > 0 else 0)

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

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

print(ans)

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

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

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

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

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

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 = a + b*(n-1) - (a*(n-1) + b) + 1
print(ans)

Solution (Python):
n,a,b=[int(_) for _ in input().split()]
if n==1:
  if a==b:
    print(1)
  else:
    print(0)
  exit()
print(max(0,(n-2)*(b-a)+1))

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy





sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))




def main():
    n, a, b = ns()

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

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

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

    minimum_sum = a * n + (b - a)
    maximum_sum = b * n - (b - a)
    print(maximum_sum - minimum_sum + 1)


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import numpy as np
import math
import scipy
import itertools

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

if __name__ == "__main__":
    solve()

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

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

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

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

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

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

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

print(ma-mi+1)

Solution (Python):
def main(n: int, a: int, b: int):
    if a > b:
        print(0)
        return

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

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

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


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

    main(n, a, b)

Solution (Python):
import sys

input = sys.stdin.readline


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

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


if __name__ == "__main__":
    main()

Solution (Python):
def resolve():
    '''
    code here
    '''
    N, A, B = [int(item) for item in input().split()]

    if A <= B:
        if N >=3:
            res = (N-1)*B + A - ((N-1)*A + B) + 1

        elif N == 2:
            res = 1
        else:
            if A == B:
                res = 1
            else:
                res = 0
    else:
        res = 0

    print(res)

if __name__ == "__main__":
    resolve()

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

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

Solution (Python):
import math
import sys

n, a, b = map(int, sys.stdin.readline().rstrip().split())

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

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

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

if B < A:
  print(0)
  exit()
num = B-A+1
mi = A*(N-1) + B
ma = B*(N-1) + A
ans = ma - mi + 1

print(max(ans,0))

Solution (Python):
n, a, b = (int(_) for _ in input().split())
if a > b or (n == 1 and a != b): print(0)
else:
  m, M = (n-1) * a + b, a + (n-1) * b
  print(M - m + 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())

sum_min = a + a * (n - 2) + b 
sum_max = a + b * (n - 2) + b

print(max(sum_max - sum_min + 1, 0))

Solution (Python):

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

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

def dp(n, cur):
    if n == 1:
        return 

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

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

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

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

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

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

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

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

mini = a * (n - 1) + b
maxi = b * (n - 1) + a

print(max(maxi - mini + 1, 0))

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


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 lcm(x, y):
    return (x * y) // gcd(x, y)


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


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


def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True



def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret



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

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

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, A, B = list(map(int,_in[0].split(' ')))  
    
    _min = A*(N-1)+B
    _max = A+B*(N-1)
    cnt = max(_max-_min+1,0)
    
    print(cnt)

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


if __name__ == '__main__':
    resolve()

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

cnt = 0

n_min = (a * (n-1)) + b
n_max = (b * (n-1)) + a

if (n_max - n_min + 1) < 0:
    result = 0
else:
    result = n_max - n_min + 1
print(result)

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

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


if a > b:
    print(0)
elif a == b and n == 1:
    print(1)
elif a != b and n == 1:
    print(0)
else:
    print(y - x + 1)

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

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

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

Solution (Python):
import sys
input=sys.stdin.buffer.readline
n,a,b=map(int,input().split())
if n==1:
    if a==b:print(1)
    if a!=b:print(0)
if n>1:
    if a>b:print(0)
    if a<=b:print((n-2)*(b-a)+1)

Solution (Python):
n, a, b = [int(i) for i in input().split()]
c = b * (n - 1) + a
d = a * (n - 1) + b

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

Solution (Python):

N, A, B = [int(s) for s in input().split()]

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

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

if A>B:
    print(0)
    exit()
elif N==1 and A!=B:
    print(0)
    exit()
MAX=A+B*(N-1)
MIN=B+A*(N-1)

print(MAX-MIN+1)

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

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

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

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

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

def main():
    mod=10**9+7
    N,A,B=MI()
    ans=0
    rem=N-2
    ans=rem*(B-A)+1
    ans=max(ans,0)
    if A>B or (rem<0 and B-A>=1):
        ans=0
    print(ans)

main()

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 heapq import heapify, heappop, heappush
 
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()

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

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N, A, B = map(int, input().split())
    if A > B: print(0)
    elif N == 1:
        if B != A: print(0)
        else: print(1)
    else:
        rem = N - 2
        minS = A + B + rem * A
        maxS = A + B + rem * B
        print(maxS - minS + 1)

    return 0

if __name__ == "__main__":
    solve()

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

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

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

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

    n_min = b + (n-1)*a
    n_max = a + (n-1)*b

    print(n_max-n_min+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()


C = N - 2
l = A * C
h = B * C
print(h - l + 1)

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

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

print (max(0, MAX - MIN + 1))

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

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

    if a > b:
        print(0)
        return

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

if __name__ == '__main__':
    main()

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

sum_min = A * (N - 1) + B
sum_max = A + B * (N - 1)

print(max(0, sum_max - sum_min + 1))

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

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


if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
def myAnswer(N:int,A:int,B:int) -> int:
   if((N== 1 and  A != B )or B - A < 0): return 0
   ans = (B*(N-1) + A) - (A * (N - 1) + B) + 1
   return ans

def modelAnswer():
   return
def main():
   N,A,B = map(int,input().split())
   print(myAnswer(N,A,B))
if __name__ == '__main__':
   main()

Solution (Python):
def myAnswer(N:int,A:int,B:int) -> int:
   if(B - A > N or B - A < 0): return 0
   ans = (B*(N-1) + A) - (A * (N - 1) + B) + 1
   return ans

def modelAnswer():
   return
def main():
   N,A,B = map(int,input().split())
   print(myAnswer(N,A,B))
if __name__ == '__main__':
   main()

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

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

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

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

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

Solution (Python):
















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

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

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

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

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

Solution (Python):


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

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

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


def log(v):
    print(v, file=sys.stderr)


N, A, B = map(int, input().split())
maxNum = A + B * (N - 1)
minNum = A * (N - 1) + B
print(max(maxNum - minNum + 1, 0))

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

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


resolve()

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

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

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