After struggling to find an answer to this exact question, and nearly giving up I was able to come up with a solution that's so simple, it hurts :). Simply envelop your variable (or your array) in a "string" (thus converting it to a string) to be able to search all of its content. For your example it would be:
contains(string(variables('ArrayNumber')),'5')
In my case, I had the following output from a SharePoint choice column that I was checking if a value exists:
[{"@odata.type":"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference","Id":0,"Value":"NORTH"},{"@odata.type":"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference","Id":1,"Value":"SOUTH"}]
I used following formula to check:
contains(string(items('Apply_to_each')?['Platform'], 'NORTH')
which returned "true" as expected.