matA[n_]:=2IdentityMatrix[n]-DiagonalMatrix[Array[(1)&,n-1],1]-DiagonalMatrix[Array[(1)&,n-1],-1]-Array[(DiscreteDelta[#1-n,#2-n])&,{n,n}]

matA[5]//MatrixForm

fqmat[n_]:=Expand[Array[B,n].matA[n].Array[B,n]]

fq[n_]:=Sum[(B[i]-B[i-1])^2,{i,1,n}]/.B[0]->0

nn=15;Simplify[fq[nn]-fqmat[nn]]

Inverse[matA[4]]//MatrixForm

Inverse[matA[5]]//MatrixForm

Inverse[matA[6]]//MatrixForm

imatA[n_]:=Array[(Min[#1,#2])&,{n,n}]

imatA[6]//MatrixForm

imatAabs[n_]:=Array[(-Abs[#1-#2]+Abs[#1]+Abs[#2])/2&,{n,n}]

imatAabs[6]//MatrixForm