#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int>> v;
int main() {
  long long int t;
  cin >> t;
  v.resize(t);
  for (long long int i = 0; i < t; i++) {
    long long int x;
    cin >> x;
    v[i] = make_pair(x, i + 1);
  }
  sort(v.begin(), v.end());
  long long int sum = 0;
  for (long long int i = 1; i < t; i++) {
    sum += abs(v[i].second - v[i - 1].second);
  }
  cout << sum;
}
