Kickstart round C 2020 -problem c -perfect subarray

here is solution of problem c
from kickstart round c 2020
solution

solved using simple logic and get correct answer for small data set but,get time limit error for big data set(10^5)…