program movingAverage
  implicit none
  integer,parameter::max_leng=30
  real,DIMENSION(1:max_leng)::x,avg
  real::sum
  integer::i,j,window,leng
  
  read(*,*) leng, (x(i),i=1, leng)
  read(*,*) window
  do i=1,leng-window+1
    sum=0.0
    do j=i,i+window-1
      sum=sum+x(j)
    enddo
    avg(i)=sum/window
  enddo
  write(*,*) 'moving average of the given array:'
  write(*,*) (avg(i),i=1,leng-window+1)
end program movingAverage
