#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, i, j, k, x, y, sum = 0, temp;
  cin >> n;
  int a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  map<int, int> mp;
  for (i = 0; i < n; i++) {
    mp[a[i]] = i + 1;
  }
  for (i = 1; i < n; i++) {
    sum += abs(mp[i] - mp[i + 1]);
  }
  cout << sum;
  return 0;
}
