If storing the array as a list of numbers isn't problematic, you can use
import heapqheapq.nlargest(N, a)
to get the N
largest members.
If storing the array as a list of numbers isn't problematic, you can use
import heapqheapq.nlargest(N, a)
to get the N
largest members.