#include <bits/stdc++.h>
using namespace std;
int n;
struct zz {
  int id, val;
} a[200005];
bool cmp(zz x, zz y) { return x.val < y.val; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].val);
    a[i].id = i;
  }
  sort(a + 1, a + n + 1, cmp);
  long long sum = 0;
  for (int i = 2; i <= n; i++) sum += abs(a[i].id - a[i - 1].id);
  printf("%lld", sum);
  return 0;
}
