How to select an environment variable from an array?

I wanted to specify defaultStage as the first entry of stage in the following variable definition, so as to avoid hardcoding defaultStage into ‘dev’.

Is there a way to achieve that? e.g., something like defaultStage: ${custom.stages.first} (note: here ‘first’ would not work)

custom:
stages:
- dev
- qa
- prod
defaultStage: dev