const
mm=1000000007;
var
n,i,j,tot:longint;
ans:int64;
a:array[1..10000] of int64;
c:array[1..100,1..100] of longint;
begin
assign(input,'necklacemn.in'); reset(input);
assign(output,'necklacemn.out'); rewrite(output);
readln(n);
for i:=1 to n do
for j:=1 to n do
read(c[i,j]);
for i:=1 to n do
for j:=i+1 to n do
begin
inc(tot);
a[tot]:=c[i,j];
end;
ans:=1;
for i:=1 to tot do
ans:=ans*(a[i]+1) mod mm;
for i:=1 to tot do
ans:=ans-a[i];
ans:=ans-1;
ans:=(ans+mm) mod mm;
writeln(ans);
close(input); close(output);
end.