• + 0 comments

    for Python3 Platform

    def workbook(n, k, arr):
        sp = 0
        page = 0
        
        for i in range(n):
            page += 1
            
            for j in range(1, arr[i]+1):
                if (j == page):
                    sp += 1
                if (j % k == 0 and j!=arr[i]):
                    page += 1
        
        return sp
    
    n, k = map(int, input().split())
    arr = list(map(int, input().split()))
    
    result = workbook(n, k, arr)
    
    print(result)