#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  pair<long long, long long> p[200000];
  for (long long i = 0; i < n; i++) {
    cin >> p[i].first;
    p[i].second = i;
  }
  sort(p, p + n);
  long long ans = 0;
  for (long long i = 1; i < n; i++) {
    ans += abs(p[i].second - p[i - 1].second);
  }
  cout << ans;
}
