Getting TLE in Java

Help needed please tell me how to optimize this code …
i am trying to solve this problem but this is not even passing the sample test case where i am doing wrong … please help

https://codeforces.com/contest/628/submission/91581523

problem link – https://codeforces.com/contest/628/problem/D