public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int chapters = in.nextInt();
		int maxProbs = in.nextInt();
		int bookPageIndex = 0;
		int magicProbs = 0;
		System.out.println("Chapters : "+chapters);
		System.out.println("Max Probs : "+maxProbs);
		for(int i=0; i<chapters; i++){
			int probsInChapter = in.nextInt();
			if(probsInChapter <= maxProbs){
				bookPageIndex++;
				if(isPageAndProbIndexMatch(bookPageIndex, 1, probsInChapter))
					magicProbs++;
			}else{
				int pageCount = probsInChapter / maxProbs;
				if(probsInChapter % maxProbs != 0)
					pageCount += 1;

				for(int j=0; j<pageCount; j++){
					bookPageIndex++;
					int probIndexStart = getProbStartIndex(j, maxProbs);
					int probIndexEnd = getProbEndIndex(j, maxProbs, probsInChapter, j==pageCount-1);
					if(isPageAndProbIndexMatch(bookPageIndex, probIndexStart, probIndexEnd))
						magicProbs++;
				}
			}
			System.out.println("Problem is "+ (i+1) +"th Chapter : "+probsInChapter);
		}
		System.out.println("Total Pages of Book : "+bookPageIndex);
		System.out.println("Magic Problems In Book : "+magicProbs);
	}