Find the next greater element

why is the code not diplaying the elements of ar ???
and y is it only executing the first cout ???