[EDIT] original title of this question was \"Getting the last element of a Postgres array, declaratively\"
How to obtain the last element of the array in Postgr
Use array_upper():
SELECT array_upper(ARRAY[1,2,5,6], 1);