#include <bits/stdc++.h>
using namespace std;
long long INF = 214748364700000;
bool visited[301][301] = {0};
long long ans = 0;
long long arr[301][301] = {0};
long long n, m;
vector<pair<long long, long long>> v[2000001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  vector<pair<long long, long long>> v;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    v.emplace_back(make_pair(a, i));
  }
  sort(v.begin(), v.end());
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    ans += abs(v[i].second - v[i - 1].second);
  }
  cout << ans << '\n';
}
