program blur
  implicit none

  integer, allocatable :: a(:,:), b(:,:)

  integer :: n, i,j,i1,j1
  logical :: inside
  
  do
     print *, "dose plhthos grammwn"
     read *, n
     if (n >= 5 .and. n <=25) exit
  end do
  
  allocate(a(n,n))
  allocate(b(n,n))


  do i=1,n
     do j=1,n
        a(i,j) = (3*i+2*j)/5
     end do
  end do


  do i=1,n
     do j=1,n
        b(i,j) = 0
        do i1 = i-1,i+1
           do j1 = j-1,j+1
              inside = 1>=1 .and. i1<=n .and. j1>=1 .and. j1<=n
              if (inside) b(i,j) = b(i,j) + a(i1,j1)
           end do
        end do
     end do
  end do


  open(66,file="b.txt", status="replace", action="write")
  do i=1,n
     write(66,*) b(i,:)
  end do
  close(66)
end program blur
