<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> of length <code>n</code>.</p>

<p>You can perform the following operation as many times as you want:</p>

<ul>
	<li>Pick an index <code>i</code> that you haven&rsquo;t picked before, and pick a prime <code>p</code> <strong>strictly less than</strong> <code>nums[i]</code>, then subtract <code>p</code> from <code>nums[i]</code>.</li>
</ul>

<p>Return <em>true if you can make <code>nums</code> a strictly increasing array using the above operation and false otherwise.</em></p>

<p>A <strong>strictly increasing array</strong> is an array whose each element is strictly greater than its preceding element.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [4,9,6,10]
<strong>Output:</strong> true
<strong>Explanation:</strong> In the first operation: Pick i = 0 and p = 3, and then subtract 3 from nums[0], so that nums becomes [1,9,6,10].
In the second operation: i = 1, p = 7, subtract 7 from nums[1], so nums becomes equal to [1,2,6,10].
After the second operation, nums is sorted in strictly increasing order, so the answer is true.</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [6,8,11,12]
<strong>Output:</strong> true
<strong>Explanation: </strong>Initially nums is sorted in strictly increasing order, so we don&#39;t need to make any operations.</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> nums = [5,8,3]
<strong>Output:</strong> false
<strong>Explanation:</strong> It can be proven that there is no way to perform operations to make nums sorted in strictly increasing order, so the answer is false.</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums.length &lt;= 1000</code></li>
	<li><code>1 &lt;= nums[i] &lt;= 1000</code></li>
	<li><code><font face="monospace">nums.length == n</font></code></li>
</ul>

class Solution:
    def primeSubOperation(self, nums: List[int]) -> bool:
      primes = self.primenumbers(1000+10)
      flag = True
      for i in range(len(nums)):
        if i == 0:
          if nums[i] > 2:
              nums[i] = self.binarysearch(primes,nums[i],0)
          if nums[i] < 0:
            falg = False
        else:
          if nums[i] >2:
            nums[i] = self.binarysearch(primes,nums[i],nums[i-1])
          if nums[i] <= nums[i-1]:
            flag = False
      print(nums)
      return flag

    def primenumbers(self,limit):
      primes =[True for i in range(limit+1)]
      p =2 
      while p*p <= limit:
        if primes[p]:
          for i in range(p*p,limit+1,p):
            primes[i]= False
        p +=1 
      prime = [num for num in range(2,limit+1) if primes[num]]
      return prime
    def binarysearch(self,primes,currelement,prevelement):
      l = 0 
      r = len(primes)-1
      while l <=r :
        mid = (l+r)//2
        if primes[mid] == currelement:
          l = mid-1
          break
        elif primes[mid] < currelement:
           l = l +1
        elif primes[mid] > currelement:
          r -=1
      while l > 0  and prevelement >= currelement - primes[l]:
        l -= 1
      if currelement-primes[l] <= prevelement:
        pass
      else:
         currelement -=primes[l]
      return currelement
"""
These test cases cover all the edge cases
[4,9,6,10]
[6,8,11,12]
[5,8,3]
[2,2]
[998,2]
[8,19,3,4,9]
"""
448