You are playing a video game and you have just reached the bonus level, where the only possible goal is to score as many points as possible. Being a perfectionist, you've decided that you won't leave this level until you've gained the maximum possible number of points there.

The bonus level consists of n small platforms placed in a line and numbered from 1 to n from left to right and (n - 1) bridges connecting adjacent platforms. The bridges between the platforms are very fragile, and for each bridge the number of times one can pass this bridge from one of its ends to the other before it collapses forever is known in advance.

The player's actions are as follows. First, he selects one of the platforms to be the starting position for his hero. After that the player can freely move the hero across the platforms moving by the undestroyed bridges. As soon as the hero finds himself on a platform with no undestroyed bridge attached to it, the level is automatically ended. The number of points scored by the player at the end of the level is calculated as the number of transitions made by the hero between the platforms. Note that if the hero started moving by a certain bridge, he has to continue moving in the same direction until he is on a platform.

Find how many points you need to score to be sure that nobody will beat your record, and move to the next level with a quiet heart.

Input

The first line contains a single integer n (2 ≤ n ≤ 105) — the number of platforms on the bonus level. The second line contains (n - 1) integers ai (1 ≤ ai ≤ 109, 1 ≤ i < n) — the number of transitions from one end to the other that the bridge between platforms i and i + 1 can bear.

Output

Print a single integer — the maximum number of points a player can get on the bonus level.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

5
2 1 2 1


Output

5

Note

One possibility of getting 5 points in the sample is starting from platform 3 and consequently moving to platforms 4, 3, 2, 1 and 2. After that the only undestroyed bridge is the bridge between platforms 4 and 5, but this bridge is too far from platform 2 where the hero is located now.
#include <bits/stdc++.h>
using namespace std;
void MAIN();
int main() {
  MAIN();
  return 0;
}
const long long N = 1e6 + 1, mod = 1e9 + 7;
int n, m, a[N], sll[N], slc[N];
long long sum[N], odd[N], even[N], turn[N], go[N];
long long cal(int i) { return turn[i - 1] - sum[i - 1]; }
void MAIN() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d", a + i);
    odd[i] = a[i] - !(a[i] & 1);
    even[i] = a[i] - (a[i] & 1);
    sum[i] = sum[i - 1] + odd[i];
  }
  for (int i = 1; i < n; ++i) {
    if (a[i] == 1) continue;
    turn[i] = turn[i - 1] + even[i];
  }
  for (int i = n - 1; i >= 1; --i) {
    if (a[i] == 1) continue;
    go[i] = go[i + 1] + even[i];
  }
  long long cur = 0, ans = max(turn[n - 1], go[1]);
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, go[i] + sum[i - 1] + cur);
    cur = max(cur, cal(i));
  }
  cur = sum[n - 1];
  printf("%lld", ans);
}
