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):
def main():
    N, A, B = map(int, input().split())

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

main()

Solution (Python):


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

if a > b:
    print 0
    exit()

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

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

Solution (Python):

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

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

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

Solution (Python):
N = input().split()

N[0] = int(N[0])
N[1] = int(N[1])
N[2] = int(N[2])

if(N[0] == 1):
    if(N[1] == N[2]):
        print("1")
        exit()
    print("0")
    exit()

if(N[1] > N[2]):
    print("0")
    exit()

print((N[2] * (N[0] -1) + N[1]) - (N[1] * (N[0] - 1) + N[2]) + 1)

Solution (Python):

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

Solution (Python):

import math
N, A, B = map(int, input().split())
if N != 1 and A <= B:
    '''
    n = math.factorial(B-A+N-2)
    a = math.factorial(N-2)
    b = math.factorial(B-A)
    print(n//(a*b))
    '''
    print((B-A)*(N-2)+1)
else:
    if A != B:
        print(0)
    else:
        print(1)

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

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

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

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

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

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

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

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

if(A > B) or (N == 1 and A != B):
	print("0")
else:
	Smin = A * (N - 1) + B
	Smax = B * (N - 1) + A

	print(Smax - Smin + 1)

Solution (Python):
def solve(n, a, b):
    if a > b:
        return 0
    if a == b:
        return 1
    
    if n == 1:
        return 0
    return (b * (n - 1) + a) - (a * (n - 1) + b) + 1

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

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

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


if __name__ == '__main__':
    main()

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

Solution (Python):



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

m0 = A*(N-1) +B
m1 = A+ (N-1)*B

ans=m1-m0+1
if ans<=0:
    ans=0
print(ans)

Solution (Python):
n = [int(i) for i in input().split()]
if n[0] == 1 and n[1] < n[2]:
    print(0)
elif n[1]>n[2]:
    print(0)
elif n[0] == 1 and n[1]==n[2]:
    print(1)
else:
    mi = n[1]*(n[0]-1)+n[2]
    ma = n[2]*(n[0]-1)+n[1]
    print(ma-mi+1)

Solution (Python):

def max(a, b):
	if a > b:
		return a
	else:
		return b



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

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def FI(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline().split())
def S(): return input()

n, a, b = LI()

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

Solution (Python):
import sys


def main():
    n, a, b = map(int, sys.stdin.readline().strip().split(" "))
    if a > b:
        print(0)
    elif a == b:
        print(1)
    else:
        if n == 1:
            print(0)
            return
        x = (n - 1) * a + b
        y = a + (n - 1) * b
        print(y - x + 1)


if __name__ == "__main__":
    main()

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

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

Solution (Python):
data = [int(x) for x in input().split()]
n = data[0]
a = data[1]
b = data[2]
maximum = b*(n-1) + a 
minmum = b + a*(n-1)
if a > b:
    print(0)
elif n == 1 and a != b:
    print(0)
else:
    print(maximum - minmum +1)

Solution (Python):
n,a,b = map(int, raw_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,raw_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):
N,A,B = map(int,raw_input().split())

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

Solution (Python):


import sys
import os

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

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

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

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

Solution (Python):


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

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

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

mn = (N - 2) * A
mx = (N - 2) * B

print (str(mx - mn + 1))

Solution (Python):
import math

N, A, B = map(int, input().split())
if A > B:
    print(0)
    exit()

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

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

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

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

Solution (Python):


import sys

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

if N < 2 and A < B:
    print(0)
    sys.exit()

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

c = B - A

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

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

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

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(0)
  else:
    print(1)
  sys.exit()

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

Solution (Python):
def solve() :
  ar = raw_input().split()
  N = int(ar[0])
  A = int(ar[1])
  B = int(ar[2])

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

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

  return count

if __name__ == '__main__' :
  print solve()

Solution (Python):
from sys import stdin
n,a,b = map(int, stdin.readline().split())
mi = (n-1)*a  + b
ma = (n-1)*b + a
ans = ma - mi + 1
print max(ans,0)

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

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

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import re
import string

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

Solution (Python):
import sys
import random

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

def rdi():
        return [ int(x) for x in rd().split() ]

N, A, B = rdi()

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

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

Solution (Python):

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

min_ = A * (N-1) + B
max_ = B * (N-1) + A
result = 0

diff = max_ - min_
if diff < 0:
    print('{}'.format(0))
else:
    print('{}'.format(diff+1))

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

a()

Solution (Python):









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

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

Solution (Python):
def solve(n, a, b):
    if a > b: return 0
    if n == 1: return 1 if a == b else 0

    x = n - 2
    return b * x - a * x + 1

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

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

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

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

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

Solution (Python):
length,min_num,max_num = (int(n) for n in input().split(" "))
if min_num > max_num or (length == 1 and min_num != max_num):
    print(0)
elif min_num == max_num or length == 2:
    print(1)
else:
    max_max = max_num * (length - 1) + min_num
    min_min = min_num * (length - 1) + max_num
    print(max_max - min_min + 1)

Solution (Python):

N, A, B = [int(n) for n in input().split()]
min_ = (N-1)*A + B
max_ = A + (N-1)*B
print(max(max_ - min_ +1, 0))

Solution (Python):
import sys

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

    if a > b:
        print(0)
        return

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

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

    print(ans)
    pass

if __name__ == '__main__':
    solve()

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

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

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,a,b = LI()
    if n == 1:
        if a == b:
            return 1
        return 0

    if a > b:
        return 0

    if n == 2:
        return 1

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


print(main())

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

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

if A>B:
    print(0)
    exit()
elif N==1:
    if A!=B:
        print(0)
    else:
        print(1)
    exit()
else:
    max_ = B*(N-1)+A
    min_ = A*(N-1)+B
    print(max_ - min_ + 1)

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

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

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

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

Solution (Python):
N, A, B = list(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, raw_input().split())
if not a <= b:
    print 0
else:
    print max((n-1)*b+a - (n-1)*a-b + 1, 0)

Solution (Python):



def array2d(d1, d2, init = None):
    return [[init for _ in range(d2)] for _ in range(d1)]


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

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

    smin = (n - 1) * a + b
    smax = (n - 1) * b + a
    print(smax - smin + 1)

main()

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

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

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

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

Solution (Python):
temp=input().split()
N=int(temp[0])
A=int(temp[1])
B=int(temp[2])

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

if(big<small):
	print(0)
elif(N==1 and big!=small):
	print(0)
else:
	print(big-small+1)

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

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

Solution (Python):
def rren(): return list(map(int, input().split()))


n, a, b = rren()

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

minsum = A + B + (N-2)*A
maxsum = A + B + (N-2)*B

print(max(0, maxsum - minsum + 1))

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

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

Solution (Python):

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


min_ = A*(N-1) + B
max_ = A + B * (N-1)

res = max_ - min_ + 1


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

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

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

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

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

Solution (Python):
from sys import stdin
rr = lambda: stdin.readline().strip()
rrM = lambda: map(int,rr().split())
debug=0
if debug:
    fi = open('in.txt','r')
    rr=lambda: fi.readline().replace('\n','')

N,A,B = rrM()
smallest = A * (N-1) + B
largest = A + B * (N-1)
print max(0,largest - smallest + 1) if A<=B else 0