import copy
class Solution(object):
    def findUnsortedSubarray(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        if len(nums)==1:
            return 0
        nums2=copy.copy(nums)
        nums.sort()
        left,right=-1,-1
        for i in range(len(nums)):
            if nums[i]!=nums2[i]:
                left=i
                break
        for j in range(len(nums)-1,-1,-1):
            if nums[j]!=nums2[j]:
                right=j
                break
        if left!=-1 and right!=-1:
            return right-left+1
        else:
            return 0
s = Solution()
nums =[2]
print(s.findUnsortedSubarray(nums))
