#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int main() {
  fast();
  int n, ans = 0;
  cin >> n;
  int x = n / 2;
  vector<int> a(x);
  for (int i = 0; i < x; i++) {
    cin >> a[i];
  }
  ans = abs((n - 1) - a[x - 1]);
  a[x - 1] = n - 1;
  for (int i = x - 2; i > 0; i--) {
    int d = 2 - (a[i + 1] - a[i]);
    if (d == 0) continue;
    a[i] = a[i] - d;
    ans += abs(d);
  }
  cout << ans << '\n';
  return 0;
}
