public int largestRectangleinHistogram(int[]hist) {
		Queue<Integer> s=Collections.asLifoQueue(new ArrayDeque<Integer>());
		int rel=0;
		for (int i=0;i<hist.length||!s.isEmpty();) {
			if (s.isEmpty()||(i<hist.length&&hist[s.peek()]<hist[i])) {s.offer(i);++i;continue;}
			int ht=hist[s.poll()]; int prev=s.isEmpty()?0:s.peek()+1;
			rel=Math.max(rel, ht*(i-prev));
		}
		return rel;
	}