HISTOGRA - Largest Rectangle in a Histogram [spoj]

I have been trying to solving HISTOGRA on spoj , but i got wrong answer,where am i doing wrong?

problem link: https://www.spoj.com/problems/HISTOGRA/

code link: https://ide.codingblocks.com/s/199277