#include<cstdio>
#include<iostream>
#define int long long
#define RI register int
#define CI const int&
using namespace std;
const int N=400005;
int n,m,k,f[N],g[N],fa[N];
inline int getfa(CI x)
{
return fa[x]!=x?fa[x]=getfa(fa[x]):x;
}
signed main()
{
scanf("%lld%lld%lld",&n,&m,&k);
for (RI i=1;i<=n;++i) scanf("%lld",&f[i]);
for (RI i=1;i<=n+m;++i) fa[i]=i;
int sum=0,ans=0;
for (RI i=1;i<=n+m-1;++i)
{
if (i-m>=1) sum-=g[i-m];
if (sum>=k) continue;
int x=getfa(i);
while (x>0&&x>i-m&&sum<k)
{
int tmp=min(f[x]-g[x],k-sum);
g[x]+=tmp; ans+=tmp; sum+=tmp;
if (f[x]==g[x]) fa[x]=getfa(x-1),x=getfa(x);
}
}
return printf("%lld",ans),0;
}