n = int(input())
v = []
for i in range(n):
v.extend(list(map(int, input().split())))
e = [0 for i in range(101010)]
for i in range(n ** 2):
if i % n:
if i >= n:
e[i] = e[i - 1] + e[i - n]
else:
e[i] = e[i - 1]
elif i >= n:
e[i] = e[i - n]
else:
e[i] = 1
d = [0 for i in range(101010)]
for i in range(n ** 2):
if i % n:
if i >= n:
d[i] = d[i - 1] + d[i - n] + e[i] * v[i]
else:
d[i] = d[i - 1] + e[i] * v[i]
else:
if i >= n:
d[i] = d[i - n] + e[i] * v[i]
else:
d[i] = e[i] * v[i]
print(d[n ** 2 - 1] % int(1e9 + 7))