#include <bits/stdc++.h>
using namespace std;
long long int mi(long long int n, long long int m) {
  long long int pw = n % m;
  long long int ex = m - 2;
  long long int ans = 1;
  while (ex) {
    if (ex & 1) ans = ans * pw % m;
    pw = pw * pw % m;
    ex >>= 1;
  }
  return ans % 1000000007;
}
long long int pw(long long int a, long long int n) {
  long long int pw = a % 1000000007;
  long long int ex = n;
  long long int ans = 1;
  while (ex) {
    if (ex & 1) ans = ans * pw % 1000000007;
    pw = pw * pw % 1000000007;
    ex >>= 1;
  }
  return ans % 1000000007;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &t : v) is >> t;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (const T &t : v) {
    os << t << " ";
  }
  os << '\n';
  return os;
}
void show(long long int x) { cout << x << " "; }
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
long long int max(long long int a, long long int b) { return a > b ? a : b; }
long long int min(long long int a, long long int b) { return a < b ? a : b; }
long long int Abs(long long int x) { return x > 0 ? x : (-x); }
long long int Ceil(long long int a, long long int b) {
  return a / b + (a % b != 0);
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> vec(n);
  for (int i = 0; i < n; i++) cin >> vec[i];
  long long int a = 0, b = 0;
  b += (vec[0] / 2);
  a = (vec[0] - b);
  map<int, bool> mp;
  mp[0] = true;
  for (int i = 1; i < n; i++) {
    if ((vec[i - 1] - vec[i]) % 2) {
      if (mp[i - 1]) {
        b += (vec[i] / 2);
        a += (vec[i] - (vec[i] / 2));
        mp[i] = true;
      } else {
        a += (vec[i] / 2);
        b += (vec[i] - (vec[i] / 2));
        mp[i] = false;
      }
    } else {
      if (mp[i - 1]) {
        a += (vec[i] / 2);
        b += (vec[i] - (vec[i] / 2));
        mp[i] = false;
      } else {
        b += (vec[i] / 2);
        a += (vec[i] - (vec[i] / 2));
        mp[i] = true;
      }
    }
  }
  cout << min(a, b);
}
int32_t main() {
  int t = 1;
  while (t--) {
    solve();
  }
}

### Prompt

Please formulate a cpp solution to the following problem:

You are given a Young diagram. 

Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 ≥ a_2 ≥ … ≥ a_n ≥ 1).

<image> Young diagram for a=[3,2,2,2,1].

Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a 1 × 2 or 2 × 1 rectangle.

Input

The first line of input contain one integer n (1 ≤ n ≤ 300 000): the number of columns in the given histogram.

The next line of input contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300 000, a_i ≥ a_{i+1}): the lengths of columns.

Output

Output one integer: the largest number of non-overlapping dominos that you can draw inside of the given Young diagram.

Example

Input


5
3 2 2 2 1


Output


4

Note

Some of the possible solutions for the example:

<image> <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int mi(long long int n, long long int m) {
  long long int pw = n % m;
  long long int ex = m - 2;
  long long int ans = 1;
  while (ex) {
    if (ex & 1) ans = ans * pw % m;
    pw = pw * pw % m;
    ex >>= 1;
  }
  return ans % 1000000007;
}
long long int pw(long long int a, long long int n) {
  long long int pw = a % 1000000007;
  long long int ex = n;
  long long int ans = 1;
  while (ex) {
    if (ex & 1) ans = ans * pw % 1000000007;
    pw = pw * pw % 1000000007;
    ex >>= 1;
  }
  return ans % 1000000007;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &t : v) is >> t;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (const T &t : v) {
    os << t << " ";
  }
  os << '\n';
  return os;
}
void show(long long int x) { cout << x << " "; }
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
long long int max(long long int a, long long int b) { return a > b ? a : b; }
long long int min(long long int a, long long int b) { return a < b ? a : b; }
long long int Abs(long long int x) { return x > 0 ? x : (-x); }
long long int Ceil(long long int a, long long int b) {
  return a / b + (a % b != 0);
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> vec(n);
  for (int i = 0; i < n; i++) cin >> vec[i];
  long long int a = 0, b = 0;
  b += (vec[0] / 2);
  a = (vec[0] - b);
  map<int, bool> mp;
  mp[0] = true;
  for (int i = 1; i < n; i++) {
    if ((vec[i - 1] - vec[i]) % 2) {
      if (mp[i - 1]) {
        b += (vec[i] / 2);
        a += (vec[i] - (vec[i] / 2));
        mp[i] = true;
      } else {
        a += (vec[i] / 2);
        b += (vec[i] - (vec[i] / 2));
        mp[i] = false;
      }
    } else {
      if (mp[i - 1]) {
        a += (vec[i] / 2);
        b += (vec[i] - (vec[i] / 2));
        mp[i] = false;
      } else {
        b += (vec[i] / 2);
        a += (vec[i] - (vec[i] / 2));
        mp[i] = true;
      }
    }
  }
  cout << min(a, b);
}
int32_t main() {
  int t = 1;
  while (t--) {
    solve();
  }
}

```