Help me in solving RAINBOWA problem

My issue

how can i solve this prblem

My code

import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here

	}
}

Problem Link: Chef and Rainbow Array Practice Coding Problem