Find The Array (Hackerearth )

Please somebody explain the entire approach step by step for this question.
Here is the link: