As others have already stated the correct answer, it is just an attempt to make it more clear :
Simulating the run :
input : arr = [1, 2, 3, -4, 0, -1] , n = 6
initialized variables : m = 1, mi = 1
let's start loop for i = 1,
[1, 2, 3, -4, 0, -1]
^^
||
m mi
so, m is changed to 2, because 2 > 1 (old value of m)
but mi remains unchanged (as 1 < 2)
i = 2
[1, 2, 3, -4, 0, -1]
^^
||
m mi
so, again m changed as above (now m = 3) , but mi remains unchanged.
i = 3
[1, 2, 3, -4, 0, -1]
^^
||
m mi
so, now m remains unchanged, but mi changed ( as -4 < 1), so mi = -4
i = 4
[1, 2, 3, -4, 0, -1]
^^
||
m mi
now, m remains unchanged, and also mi remains unchanged.
i = 5
[1, 2, 3, -4, 0, -1]
^^
||
m mi
finally, loop ends with m = 3, and mi = -4.
Hence, each element is visited only once that means in the worst case, it is going to visit till the maximum length of array that is n, that means algorithm is scalable in linear order i.e. 0(n)