#include <bits/stdc++.h>
using namespace std;
int t[55][55];
int getSum(int x1, int y1, int x2, int y2) {
return t[x2+1][y2+1] - t[x2+1][y1] - t[x1][y2+1] + t[x1][y1];
}
unordered_map<pair<int, pair<int, int> >, int > st1;
unordered_map<pair<int, pair<int, int> >, int> st2;
unordered_map<pair<int, pair<int, int> >, int> st3;
unordered_map<pair<int, pair<int, int> >, int> st4;
int main() {
int n;
cin>>n;
for(int i = 0; i < n ;++i) {
for(int j = 0; j < n; ++j) {
cin>>t[i+1][j+1];
t[i+1][j+1] += t[i][j+1] + t[i+1][j] - t[i][j];
//cout<<t[i+1][j+1]<<' ';
}
//cout<<'\n';
}
for(int i = 0; i < n; ++i) {
for(int j = 0; j < n ;++j) {
for(int k = i; k < n; ++k) {
for(int l = j; l < n; ++l) {
int sum = getSum(i, j, k, l);
st1[{sum, {i, j}}]++;
st2[{sum, {k+1, j}}]++;
st3[{sum, {k+1, l+1}}]++;
st4[{sum, {i, l+1}}]++;
}
}
}
}
long long ans = 0;
for(int i = 0; i < n; ++i) {
for(int j = 0; j < n ;++j) {
// cout<<getSum(i, j,i , j)<<' ';// st1[{getSum(i, j, i, j), {i, j}}]<<' ';
for(int k = i; k < n; ++k) {
for(int l = j; l < n; ++l) {
int sum = getSum(i, j, k, l);
ans += st1[{sum, {k+1, l+1}}];
ans += st2[{sum, {i, l+1}}];
ans += st3[{sum, {i, j}}];
ans += st4[{sum, {k+1, j}}];
}
}
}
// cout<<'\n';
}
cout<<ans/2<<'\n';
}