#include #include #include #include using std::vector; using std::set; using std::priority_queue; struct Node{ int d; int need; int t; bool operator < (const Node& other) const{ return d < other.d; } }; int main(){ int n; scanf("%d",&n); vector a(n); long long ans = 0; for(int i = 1; i <= n; i++){ int u; scanf("%d",&u); if(u != i){ if(u>i) ans -= 1ll*i; else ans += 1ll*i; } } printf("%lld\n",ans); return 0; }