#include <bits/stdc++.h>
using namespace std;
int f[200001], a[200001];
bool cmp(int x, int y) { return f[x] < f[y]; }
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    cin >> f[i];
  }
  for (int i = 1; i <= n; i++) {
    a[i] = i;
  }
  sort(a + 1, a + 1 + n, cmp);
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    ans += abs(a[i] - a[i + 1]);
  }
  cout << ans;
  return 0;
}
