#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<vector<int>> seat(n, vector<int>(n));
  int num = 1;
  vector<vector<int>> score(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      seat[i][j] = num;
      num++;
      if (i - 0 < j - 0) {
        if (i - 0 < n - 1 - i) {
          if (i - 0 < n - 1 - j) {
            score[i][j] = i - 0;
          } else if (i - 0 >= n - 1 - j) {
            score[i][j] = n - 1 - j;
          }
        } else if (i - 0 >= n - 1 - i) {
          if (n - 1 - i < n - 1 - j) {
            score[i][j] = n - 1 - i;
          } else if (n - 1 - i >= n - 1 - j) {
            score[i][j] = n - 1 - j;
          }
        }
      } else if (i - 0 >= j - 0) {
        if (j - 0 < n - 1 - i) {
          if (j - 0 < n - 1 - j) {
            score[i][j] = j - 0;
          } else if (j - 0 >= n - 1 - j) {
            score[i][j] = n - 1 - j;
          }
        } else if (j - 0 >= n - 1 - i) {
          if (n - 1 - i < n - 1 - j) {
            score[i][j] = n - 1 - i;
          } else if (n - 1 - i >= n - 1 - j) {
            score[i][j] = n - 1 - j;
          }
        }
      }
    }
  }
  vector<int> p(n * n);
  for (int i = 0; i < n * n; i++) {
    cin >> p[i];
  }
  vector<int> vx = {0, 1, 0, -1};
  vector<int> vy = {1, 0, -1, 0};
  queue<int> q;
  q.push(p[0]);
  int ans = 0, row = 0, col = 0;
  for (int i = 0; i < n * n; i++) {
    if (p[i] % n == 0) {
      row = p[i] / n - 1;
      col = n - 1;
    } else {
      row = p[i] / n;
      col = p[i] % n - 1;
    }
    ans += score[row][col];
    cout << ans << endl;
    while (!q.empty()) {
      q.pop();
      for (int j = 0; j < n; j++) {
        if (score[row][col] > score[row + vx[j]][col + vy[j]]) {
          q.push(score[row + vx[j]][col + vy[j]]);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
