get last array element without modifying array