#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > vii;
long double PI = 3.1415926535898;
int main() {
  int n;
  long long ans = 0;
  cin >> n;
  for (int i = 1, temp; i <= n; i++) {
    cin >> temp;
    vii.push_back(make_pair(temp, i));
  }
  sort(vii.begin(), vii.end());
  for (int i = 1; i < n; i++) {
    ans += abs(vii[i].second - vii[i - 1].second);
  }
  cout << ans;
  return 0;
}
