How to replace the number of each element of a matrix with a subscript?

I want to get the matrix as Figure 2. There should be two ways to achieve the result.

  1. There is a matrix as Figure 1, and change it to the form of Figure 2.

  2. Generating the matrix as Figure 2 directly.

How can I do it? Thanks.

Noteļ¼šThe matrix in Figure 2 is a symmetric matrix

Figure 1

enter image description here

Figure 2

enter image description here