Vanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the processor doesn't exceed h and the processor smashes k centimeters of potato each second. If there are less than k centimeters remaining, than during this second processor smashes all the remaining potato.

Vanya has n pieces of potato, the height of the i-th piece is equal to a_{i}. He puts them in the food processor one by one starting from the piece number 1 and finishing with piece number n. Formally, each second the following happens:

  If there is at least one piece of potato remaining, Vanya puts them in the processor one by one, until there is not enough space for the next piece.  Processor smashes k centimeters of potato (or just everything that is inside). 

Provided the information about the parameter of the food processor and the size of each potato in a row, compute how long will it take for all the potato to become smashed.


-----Input-----

The first line of the input contains integers n, h and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ h ≤ 10^9) — the number of pieces of potato, the height of the food processor and the amount of potato being smashed each second, respectively.

The second line contains n integers a_{i} (1 ≤ a_{i} ≤ h) — the heights of the pieces.


-----Output-----

Print a single integer — the number of seconds required to smash all the potatoes following the process described in the problem statement.


-----Examples-----
Input
5 6 3
5 4 3 2 1

Output
5

Input
5 6 3
5 5 5 5 5

Output
10

Input
5 6 3
1 2 1 1 1

Output
2



-----Note-----

Consider the first sample.   First Vanya puts the piece of potato of height 5 into processor. At the end of the second there is only amount of height 2 remaining inside.  Now Vanya puts the piece of potato of height 4. At the end of the second there is amount of height 3 remaining.  Vanya puts the piece of height 3 inside and again there are only 3 centimeters remaining at the end of this second.  Vanya finally puts the pieces of height 2 and 1 inside. At the end of the second the height of potato in the processor is equal to 3.  During this second processor finally smashes all the remaining potato and the process finishes. 

In the second sample, Vanya puts the piece of height 5 inside and waits for 2 seconds while it is completely smashed. Then he repeats the same process for 4 other pieces. The total time is equal to 2·5 = 10 seconds.

In the third sample, Vanya simply puts all the potato inside the processor and waits 2 seconds.

Difficulty: interview

Starter code:

Solutions:
n, h, k = [int(x) for x in input().split()]
L=[int(x) for x in input().split()]
L = L[::-1]
p = 0
t = 0
while L:
    if L and h-p >= L[-1]:
        p+=L.pop()
    if L:
        req = L[-1]-h+p
        inc = (req-1)//k + 1
        t += inc
        p -= inc*k
        p=max(p,0)

if p:
    t += (p-1)//k + 1

print(t)


n,h,k=list(map(int,input().split()))
xs=list(map(int,input().split()))+[h+1]
t=0
x=0
i=0
while i+1<len(xs) or x>0:
    while x+xs[i]<=h:
        x+=xs[i]
        i+=1
    d=max(1,min(x,x-h+xs[i]+k-1)//k)
    x=max(0,x-d*k)
    t+=d
print(t)


n, h, k = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = 0
rem = 0
i = 0
while i < n:
    while rem <= h and i < n:
        rem += A[i]
        i += 1
    if rem > h:
        i -= 1
        rem -= A[i]
    ans += rem // k
    rem %= k
    if i < n and rem + A[i] > h:
        ans += 1
        rem = 0
if rem > 0:
    ans += 1
print(ans)


read = lambda: list(map(int, input().split()))
n, h, k = read()
a = list(read())
ans = rem = 0
for i in range(n):
    if rem != 0 and rem + a[i] > h:
        ans += 1
    else:
        a[i] += rem
    ans += a[i] // k
    rem = a[i] % k
if rem != 0:
    ans += 1
print(ans)
    


#!/usr/bin/env python3

N, H, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

result = 0
fill = 0
p = 0

while p < len(A) or fill != 0:
    while p < len(A) and fill + A[p] <= H:
        fill += A[p]
        p += 1

    if p < len(A):
        need = A[p] - (H - fill)
    else:
        need = fill

    time = (need + K - 1) // K
    fill = max(0, fill - time * K)
    result += time

print(result)


n, h, k = map(int, input().split())
a, ai, c, t = list(map(int, input().split())), 0, 0, 0
while c > 0 or ai < n:
    while ai < n and c + a[ai] <= h:
        c += a[ai]
        ai += 1
    if c < k:
        t += 1
        c = 0
    else:
        t += c // k
        c %= k
print(t)

# coding: utf-8





import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect

def array2d(d1, d2, init = None):
    return [[init for _ in range(d1)] for _ in range(d2)]


n, h, k = list(map(int, input().split(" ")))
al = list(map(int, input().split(" ")))
in_proc = 0
pointer = 0
time = 0

for a in al:
    if a > h - in_proc:
        time += in_proc // k
        in_proc %= k
        if a > h - in_proc:
            time += 1
            in_proc = 0
    in_proc += a

time += in_proc // k
in_proc %= k
time += (in_proc > 0)
print(time)


n, h, k = list(map(int, input().split()))
a = list(map(int, input().split()))
t = 0
l = 0
i = 0
while True:
    while i < n and h - l >= a[i]:
        l += a[i]
        i += 1
    if l <= k:
        t += 1
        l = 0
    t += l // k
    l %= k
    if i == n and l == 0:
        break
print(t)
        
        


n, h, k = list(map(int, input().split()))
a = [int(x) for x in input().split()]
moulin = 0
ans = 0
for x in a:
    if moulin + x <= h:
        moulin += x
    else:
        ready = (x - h + moulin + k - 1) // k
        passed = min(ready, (moulin + k - 1) // k)
        ans += passed 
        moulin = max(0, moulin - k * passed)
        moulin += x
ans += (moulin + k - 1) // k
print(ans)



#import sys
#sys.stdin = open("python/in", "r")

#n = int(input())
n, h, k = [int(i) for i in input().split(" ")]
arr = [int(i) for i in input().split(" ")]
arr.append(h)
ans = 0
ch = 0
i = 0
while True:
    while h - ch >= arr[i]:
        ch += arr[i]
        i += 1
    d, m = divmod(ch, k)
    ans += d
    if h - m >= arr[i]:
        ch = m
    else:
        ans += 1
        ch = 0
    if i == n:
        break
print(ans)


import math

n,h,k = (int(i) for i in input().split())
l = list(map(int,input().split()))
ans = 0
i = 0
dh = 0
while i < n:
    if dh+l[i]<=h:
        dh+=l[i]
        i+=1
    else:
        ans+=math.ceil((l[i]-(h-dh))/k)
        dh = max(dh-k*math.ceil((l[i]-(h-dh))/k),0)

        
        

    
    
ans+= math.ceil(dh/k)

print(ans)


n, h, k = (int(x) for x in input().split())
a = [int(x) for x in input().split()]

t, p, i = 0, 0, 0
while i < len(a) or p > 0:
    #print(i, "<", len(a), "and", h, "-", p, "<=", a[i])
    while i < len(a) and p+a[i] <= h:
        p += a[i]
        i += 1
    if p >= k:
        q = p // k
        p = p - q*k
        t += q
    else:
        p = 0
        t += 1
print(t)


3
# Copyright (C) 2016 Sayutin Dmitry.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; version 3
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; If not, see <http://www.gnu.org/licenses/>.

def main():
    n, h, k = list(map(int, input().split()))
    dat = list(map(int, input().split()))

    ptr = 0
    t = 0
    cur = 0
    while ptr != len(dat):
        if cur + dat[ptr] > h:
            mindecr = cur + dat[ptr] - h
            dt = (mindecr + k - 1) // k
            t += dt
            
            cur = max(0, cur - dt * k)
            continue
        
        while ptr != len(dat) and cur + dat[ptr] <= h:
            cur += dat[ptr]
            ptr += 1
        cur = max(0, cur - k)
        t += 1
    t += (cur + k - 1) // k
    print(t)
main()


n, h, k = map(int, input().split())
hei = list(map(int, input().split()))
sec = 0
cur = 0
i = 0
while i < len(hei):
    sec += cur // k
    cur = cur % k
    if i < len(hei) and cur + hei[i] > h:
        sec += cur // k + 1
        cur = 0
        cur += hei[i]
        i += 1
    while i < len(hei) and cur + hei[i] <= h:
        cur += hei[i]
        i += 1
sec += cur // k
cur = cur % k
if cur != 0: sec += 1
print(sec)

def solve(n,h,v,A):
    cnt = 0
    curh = A[0]
    for i in range(1,n):
        if A[i]+curh<=h:
            curh += A[i]
        else:
            quan = int((A[i]+curh-h)/v) + ((A[i]+curh-h) % v > 0)
            cnt += quan
            curh = max(curh - quan*v, 0)
            curh += A[i]
    cnt += int(curh/v) + (curh % v > 0)
    return cnt
    
(n,h,k) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
print(solve(n,h,k,A))

import math
n, h, k = map(int, input().split())

seconds = 0
filledSpace = 0
potatoes = list(map(int, input().split()))

for p in potatoes:
    if p + filledSpace <= h:
        filledSpace += p
    else:
        s = math.ceil((p - (h - filledSpace))/k)
        if s * k > filledSpace:
            filledSpace = 0
        else:
            filledSpace -= s * k
        seconds += s
        filledSpace += p

s = math.ceil(filledSpace / k)
seconds += s

print(str(seconds))

import sys

def main():
    t = sys.stdin.readline().split()
    n = int(t[0])
    h = int(t[1])
    k = int(t[2])
    line = sys.stdin.readline()
    x = list(map(int,line.split()))
    
    res = 0
    cur = 0
    for i in range(n):
        cur += x[i]
        if i!=n-1:
            if x[i+1]+cur <= h:
                continue        
        v = int(cur/k)
        if v*k != cur :
            cur = cur - v*k
            res+= v
            if i!=n-1:
                if x[i+1]+cur > h:
                    res+=1
                    cur=0
            else:
                res+=1
        else :
            cur =0
            res +=v
        
    print(res)

main()

n,h,k=map(int,input().split())
hh=0
ans=0
for x in list(map(int,input().split())):
    if hh+x<=h:
        hh+=x
        ans+=hh//k
        hh%=k
    else:
        ans+=1
        hh=x%k
        ans+=x//k
print(ans+(hh>0))

n,h,k=map(int,input().split())
a=list(map(int,input().split()))[::-1]
ans=b=0
while a!=[]:
    while len(a) and b+a[-1]<=h: 
        b=b+a.pop()
    if b//k==0: ans,b=ans+1,0    
    else: ans,b=ans+b//k,b%k
print(ans+(b>0))

import math


n, h, k = list(map(int, input().split()))
a = list(map(int, input().split()))

current_height = 0
seconds_past = 0

i = 0
while i < len(a):
    # print(current_height, seconds_past, a[i])
    if current_height + a[i] <= h:
        current_height += a[i]
        i += 1
    else:
        if current_height <= k:
            current_height = 0
            seconds_past += 1
        else:
            seconds_past += current_height // k
            current_height = current_height % k

# print('-----')

seconds_past += math.ceil(current_height / k)

print(seconds_past)



d=input().split()
d=[int(x) for x in d]
n,h,k=d[0],d[1],d[2]
d=input().split()
d=[int(x) for x in d]
S=0
R=0
for i in d:

    if R+i<=h:
        S+=i//k
        R+=i%k 
    else:
        while R+i>h:
            if R%k==0:
                S+=R//k
                R=0
            elif R<k:
                S+=1
                R=0
            else:
                S+=R//k
                R=R%k
        S+=i//k
        R+=i%k
      
if R%k==0:
    S+=R//k
else:
    S+=R//k
    S+=1
print(S)


n,h,k=list(map(int,input().split()))
ip=list(map(int,input().split()))
time=0
count=0
height=0
while count<n:
    if height + ip[count]<= h:
        height+=ip[count]
        count+=1
    else:
        if height%k==0:
            time+=height//k
            height=0
        elif height>=k:
            time+=height//k
            height=height%k
        else:
            height-=min(k,height)
            time+=1
    #print(height,time,count)
if height==0:
    s=0
elif height%k==0:
    s=height//k
else:
    s=(height//k)+1
print(time+s)


[n,h,k]=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.insert(0,0)
pref=[0]
for i in a:
    pref.append(pref[-1]+i)
free=[h]*(n+1)
answer=[0]*(n+1)
for i in range(1,n+1):
    if a[i]<=free[i-1]:
        answer[i]=answer[i-1]
        free[i]=free[i-1]-a[i]
    else:
        answer[i] =(a[i]-free[i-1])//k+1
        if (a[i]-free[i-1])%k==0: answer[i]-=1
        free[i]=free[i-1]+answer[i]*k
        if free[i]>h: free[i]=h
        free[i]-=a[i]
        answer[i]+=answer[i-1]
answer[n]+=(h-free[n])//k
if (h-free[n])%k!=0: answer[n]+=1
print(answer[n])

n, h, k = map(int, input().split())
a = list(map(int, input().split()))
h1 = 0
ans = 0
i = 0
while i < n:
    while i < n and h1 + a[i] <= h:
        h1 += a[i]
        i += 1
    if h1 < k:
        ans += 1
        h1 = 0
    ans += h1 // k
    h1 %= k
if (h1 != 0):
    ans += 1
print(ans)   

n, h, k = list(map(int, input().split()))
a = list(map(int, input().split()))
num = 0
time = 0
s = 0
while num < n:
    time += 1
    while num < n and a[num] + s <= h:
        s += a[num]
        num += 1
    s = max(s - k, 0)
    if num < n and s > h - a[num]:
        d = (s - h + a[num] + k - 1) // k
        time += d
        s = max(s - d * k, 0)
print(time + (s + k - 1) // k)