using an array helps?

cs gods please don't hate me