#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline _T sqr(const _T& x) {
  return x * x;
}
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const long double PI = 3.1415926535897932384626433832795L;
const long double EPS = 1e-11;
char TEMPORARY_CHAR;
const int INF = 0x3f3f3f3f;
const int N = 1 << 16;
inline void input(int& a) {
  a = 0;
  while ((TEMPORARY_CHAR = getchar()) > '9' || TEMPORARY_CHAR < '0') {
  }
  while (TEMPORARY_CHAR <= '9' && TEMPORARY_CHAR >= '0') {
    a = (a << 3) + (a << 1) + TEMPORARY_CHAR - '0';
    TEMPORARY_CHAR = getchar();
  }
}
bool cmp(pair<int, int> a, pair<int, int> b) {
  return a.first < b.first || (a.first == b.first && a.second < b.second);
}
int main() {
  int(n);
  input((n));
  ;
  int a[100][100];
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(n); j++) cin >> a[i][j];
  vector<pair<int, int> > t;
  for (int i = 0; i < (int)(n); i++) {
    int s1 = 0;
    int s2 = 0;
    for (int j = 0; j < (int)(n); j++) {
      s1 += a[i][j];
      s2 += a[j][i];
    }
    t.push_back(make_pair(s1, 1));
    t.push_back(make_pair(s2, 0));
  }
  sort((t).begin(), (t).end(), cmp);
  int ans = 0;
  int col = 0;
  for (__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++) {
    if (it->second) {
      col++;
    } else {
      ans += col;
    }
  }
  cout << ans;
  return 0;
}
