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 sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

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

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

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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 LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    n,a,b = LI()
    if b < a:
        print(0)
        return
    if n == 1 and a != b:
        print(0)
        return
    mi = a*(n-1)+b
    ma = b*(n-1)+a
    print(abs(ma-mi)+1)
    return

def B():

    return


def C():

    return


def D():

    return


def E():

    return


def F():

    return


if __name__ == "__main__":
    A()

Solution (Python):

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

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

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

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

    maxv = B*(N-1) + A
    minv = A*(N-1) + B
    return maxv - minv + 1

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

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

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

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

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

mid_num = n - 2

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

print(b * mid_num - a * mid_num + 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(A+B*(N-1) - (A*(N-1)+B) + 1)

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

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

Solution (Python):
n, a, b = [ int(v) for v in input().split() ]
if n == 1:
    if a != b:
        ans = 0
    else:
        ans = 1
else:
    if a <= b:
        maxsum = a + b*(n-1)
        minsum = a*(n-1) + b
        ans = maxsum - minsum + 1

    else:
        ans = 0
print(ans)

Solution (Python):


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

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

Solution (Python):

import sys, math, fractions, itertools, collections, copy, heapq


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

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

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

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

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

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



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

print(ans)

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

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

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

Solution (Python):
def main():
    N, A, B = [int(i) for i in input().split()]
    res = (B - A) * (N-2) + 1
    print(res if res > 0 else 0)

    

main()

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

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

Solution (Python):

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


if __name__ == "__main__":
    main()

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

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

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


if __name__ == "__main__":
    main()

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

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

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

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

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

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


if __name__ == "__main__":
    main()

Solution (Python):

import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
MOD = 10**9 + 7
sys.setrecursionlimit(10**7)

dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())


N, A, B = mi()

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

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

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

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

ans = 0

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

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

print(ans)

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

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

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

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

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

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

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

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

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):
def main():
    N, A, B = map(int, input().split())
    if A > B or (N <= 1 and A != B):
        print(0)
        return
    ans = (A + B * (N-1)) - (A * (N-1) + B) + 1
    print(ans)


if __name__ == "__main__":
    main()

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

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

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

Solution (Python):




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

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

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

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

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

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

print(sum_max - sum_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()
    else:
        print(1)
        exit()

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

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

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

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

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

x = A * (N-1) + B
y = B * (N-1) + A

if N == 1 and A != B:
  answer = 0
elif A > B:
  answer = 0
else:
  answer = y - x + 1

print(answer)

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

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

N -= 1
if A != B:
  N -= 1
if A > B:
  N = -1

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

Solution (Python):

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

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

Solution (Python):
s = input().split(" ");
n = int(s[0]);
a = int(s[1]);
b = int(s[2]);
if a > b :
  print(0);
else :
  if n == 1 :
    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())
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):
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
if A > B or ((N == 1) and (A != B)):
  print(0)
else:
  min_ = A * (N - 1) + B
  max_ = B * (N - 1) + A
  print(max_ - min_ + 1)

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

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

Solution (Python):


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

Solution (Python):


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

Solution (Python):



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

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

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

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

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

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):
N ,A,B  =list(map(int,input().split(" ")))
N - 2
ab = A+B

if  A > B : 
    print(0)

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

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

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

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

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

Solution (Python):

"""
A - A+...+B Problem
https://atcoder.jp/contests/agc015/tasks/agc015_a

"""
import sys


def solve(N, A, B):
    if A > B:
        return 0
    if N == 1 and A != B:
        return 0
    left = A * (N - 2)
    right = B * (N - 2)
    return right - left + 1


def main(args):
    N, A, B = map(int, input().split())
    ans = solve(N, A, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[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 B<A 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 not A <= B:
    print(0)
    exit()
if N == 1:
    if A == B:
        print(1)
    else:
        print(0)
    exit()
if N == 2:
    print(1)
    exit()

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

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

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

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

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

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

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

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 = [int(x) for x in input().split()]

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

print(ans)

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

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

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

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

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

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

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

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

Solution (Python):
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( a+b*(n-1) - (a*(n-1)+b) +1 )

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

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

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

print(ans)

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

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

print(ans)

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

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

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

Solution (Python):


import sys
import math

INF = float('inf')
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 LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


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

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


print(main())

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

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

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

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

N -= 2
Ans = (B - A) * N + 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 or 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) or A>B:
	print('0')
else:
	print(str(int((N-2)*(B-A)+1)))

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

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

    print(mx - mn + 1)

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

if n == 1 and a == b:
    print(1)

elif a > b or n == 1:
    print(0)

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

Solution (Python):
nums = input()
nums = nums.split(' ')
n = int(nums[0])
a = int(nums[1])
b = int(nums[2])
if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
    exit(0)
if a > b:
    print(0)
    exit(0)
num = b*(n-2) - a*(n-2) + 1
print(num)

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

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

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

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

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

if a > b or (n < 2 and a != b):
    ans = 0
elif a == b:
    ans = 1
else:
    x = n - 2
    mina = a * x
    maxb = b * x
    ans = maxb - mina + 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)
else:
    print((a+(n-1)*b) - (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())

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

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

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


if __name__ == '__main__':
    main()

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

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

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

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

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

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

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

hanni = B-A+1
N -= 2

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

if hanni <= 0 or N <= 0:
    print(0)
else:
    ans = (hanni-1)*N+1
    print(ans)

Solution (Python):
import math
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:
    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())
M=a+b*(n-1)
m=a*(n-1)+b
print(int(a==b) if n==1 else max(M-m+1,0))

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 = (int(i) for i in input().split())
if a >b:
  print(0)
  exit()
elif n == 1 and a!=b:
  print(0)
  exit()
if n<= 2:
  print(1)
else:
  mi = a*(n-1)+b
  ma = a+(n-1)*b
  print(ma-mi+1)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

Solution (Python):


import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
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:
    print(0)
elif A == B:
    print(1)
else:
    if N < 2:
        print(0)
    elif N == 2:
        print(1)
    
    else:
        print(A + B*(N-1) - (A*(N-1) + B)+1)

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

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

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