#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long double EPS = 1e-8;
signed main() {
  int N;
  N = 500;
  vector<int> P(N * N);
  for (long long i = (0); i < (N * N); i++) P[i] = i;
  random_shuffle((P).begin(), (P).end());
  vector<vector<pair<int, int>>> distance(N, vector<pair<int, int>>(N));
  vector<vector<bool>> exist(N, vector<bool>(N, true));
  for (long long i = (0); i < (N); i++)
    for (long long j = (0); j < (N); j++) {
      vector<pair<long long, int>> el = {
          {i, -1}, {j, -1}, {N - i - 1, -1}, {N - j - 1, -1}};
      distance[i][j] = *min_element((el).begin(), (el).end());
    }
  long long answer = 0;
  const vector<int> dx = {1, 0, 0, -1}, dy = {0, 1, -1, 0};
  for (long long i = (0); i < (N * N); i++) {
    int x = P[i] % N;
    int y = (P[i] - x) / N;
    answer += distance[y][x].first;
    exist[y][x] = false;
    queue<pair<int, int>> que;
    que.push({x, y});
    while (!que.empty()) {
      auto current = que.front();
      que.pop();
      for (long long j = (0); j < (4); j++) {
        pair<int, int> next = {current.first + dx[j], current.second + dy[j]};
        if (next.first < 0 || next.first >= N || next.second < 0 ||
            next.second >= N)
          continue;
        if (distance[next.second][next.first].second == i) continue;
        int update = distance[current.second][current.first].first +
                     (exist[current.second][current.first] ? 1 : 0);
        if (distance[next.second][next.first].first > update) {
          distance[next.second][next.first] = {update, i};
          que.push(next);
        }
      }
    }
  }
  cout << answer << endl;
  return 0;
}
