#include <bits/stdc++.h>
using namespace std;
long long n, i;
struct lwn {
  long long x, y;
  bool operator<(const lwn &jb) const { return x < jb.x; }
} a[200050];
int get_val() {
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  int rent = 0;
  while (ch >= '0' && ch <= '9') {
    rent = rent * 10 + ch - '0';
    ch = getchar();
  }
  return rent;
}
int main() {
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i].x);
  for (i = 1; i <= n; i++) a[i].y = i;
  sort(a + 1, a + n + 1);
  long long ans = 0;
  for (i = 1; i < n; i++) ans += abs(a[i].y - a[i + 1].y);
  printf("%lld\n", ans);
  return 0;
}
