use two stacks, one is mainstack, the other always keep the min element