Postgres- update a value in a array on particular index

I have a column named ids that is of type bigint[]. ids cane be null or of any length

It has values based on certain hierarchy.

My use case is I want to update value that is at a particular index. For example ids[2] = 50.

How can I achieve this?

I looked at this but couldn’t find anything that could help.

Thanks in advance.