<prompt> 10, 20, 30, 40Kuandika programu ya kupata RMQ ya safu ya integer.  <response>: Here is a Python implementation using the Segment Tree data structure, which has a time complexity of Olog n for both construction and querying:pythonclass SegmentTree: def __init__self, arr: self.arr arr self.n lenarr create a list to store nodes of segment tree self.tree None 4 self.n self.build0, 0, self.n - 1 def buildself, node, start, end: if start end: leaf node stores the value of individual element self.treenode self.arrstart else: mid start end 2 recursively build left and right subtree self.build2 node 1, start, mid self.build2 node 2, mid 1, end store minimum value of left and right subtree self.treenode minself.tree2 node 1, self.tree2 node 2 def queryself, node, start, end, left, right: if left end or right start: case when query range is completely outside current segment return floatinf if left start and right end: case when query range completely overlaps current segment return self.treenode mid start end 2 recursively go to left and right subtree and return minimum value return minself.query2 node 1, start, mid, left, right, self.query2 node 2, mid 1, end, left, right example usagearr 10, 20, 30, 40tree SegmentTreearrprinttree.query0, 0, tree.n - 1, 1, 2 output: 20In the above code, the SegmentTree class has two methods: build for constructing the segment tree recursively, and query for finding the minimum value within a given range. In the build method, the base case is when the start and end indices are equal, which means we have reached a leaf node. Otherwise, we divide the array into two halves and recursively create the left and right subtrees. The minimum value of each node is the minimum of the nodes in its two children. In the query method, we have several scenarios to consider: if the query range is completely outside the current segment, return infinity; if the query range completely overlaps the current segment, return the value at the current node; otherwise, recursively go to the left and right subtree and return the minimum value of the two. Finally, we initialize an instance of the SegmentTree class with the input array, and call the query method with a given range to find the RMQ of the array. 