#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long MAX = 2e5 + 5;
long long per[MAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(25);
  long long n, i, j, k;
  cin >> n;
  long long a;
  for (i = 1; i <= n; i++) {
    cin >> a;
    per[a] = i;
  }
  long long ans = 0;
  for (i = 1; i < n; i++) {
    ans += abs(per[i] - per[i + 1]);
  }
  cout << ans;
  return 0;
}
