Help me in solving GLOBALWARMIN problem

My issue

unable to understand the questions at the point of edges

My code

# cook your dish here
a=[1,1,1,2,2,1,2,1,2................n-1]
a1[1,1]
a2=[1,1]
a3=[1,2,2]
a4=[2,2,1]
a5=[1,2]

Problem Link: Global Warming Practice Coding Problem