reverse the given array