Help me in solving PANSTACK problem

My issue

plz give the approach of this question

My code

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

class Codechef
{
    int final mod=1000000007;
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here

	}
}

Problem Link: Stacking Pancakes Practice Coding Problem - CodeChef