#include<stdio.h>

FILE *fin,*fout;

long long n,k,f[1100005],dp[1100005],i;

int main()
{
 fin=fopen("zetoni.in", "r");
 fout=fopen("zetoni.out", "w");
 fscanf(fin,"%lld%lld",&n,&k);
 for(i=1;i<=n;i++)
 {
  fscanf(fin,"%lld",&f[i]);
  f[i]=k-f[i];
 }
 for(i=1;i<=n;i++)
 {
  if(f[i]>=f[i-1])
  {
   dp[i]=dp[i-1]+f[i]-f[i-1];
  }
  else
  {
   dp[i]=dp[i-1];
  }
 }
 fprintf(fout,"%lld",dp[n]);
 return 0;
}
