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