Depends on your Data set. Not enough info provided to give you a Solution. I assume your Data will not be sorted and always +1 on the following Element, if thats the case you don´t even have to have a Array in the first place.
Hmm not sure how to guide you on the right path now but take a look at this Video how to approach something like that step by step. Might also be helpfull for you to look into Search/Sort Algorithms and learn a bit about Big(O) notations and what they mean.
Good Luck mate =)