#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 111111;
const int MOD = 1e9 + 7;
int n;
pair<int, int> a[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long ans = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a, a + n);
  for (int i = 0; i < n - 1; ++i) ans += abs(a[i].second - a[i + 1].second);
  cout << ans;
}
