Postgres Loop Through Array Backwards Design