#include using namespace std; using ll = long long; int main() { int n; cin >> n; vector b(n); for (int i = 0; i < n; i++) { cin >> b.at(i); } ll ans = 0; int sum = 0; for (int i = 0; i < n; i++) { sum += b.at(i); ans += (ll)abs(i + 1 - sum); } cout << ans << endl; }