#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int nax = 1e6 + 10;
vector<int> tree(4 * nax);
long long i, j, x, y, k, val, a, b, c, d, n;
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.second < b.second);
}
class bitmask {
 public:
  void PowerSet(char *set, int set_size) {
    unsigned int pow_set_size = pow(2, set_size);
    int counter, j;
    for (counter = 0; counter < pow_set_size; counter++) {
      for (j = 0; j < set_size; j++) {
        if (counter & (1 << j)) cout << set[j];
      }
      cout << endl;
    }
  }
};
long long powerLL(long long x, long long n) {
  long long result = 1;
  while (n) {
    if (n & 1) result = result * x % MOD;
    n = n / 2;
    x = x * x % MOD;
  }
  return result;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  long long sum = 0;
  vector<pair<long long, long long>> v;
  for (i = 0; i < n; i++) {
    cin >> val;
    v.push_back(make_pair(val, i + 1));
  }
  sort(v.begin(), v.end());
  for (i = 1; i < v.size(); i++) {
    sum += abs(v[i].second - v[i - 1].second);
  }
  cout << sum << endl;
}
