Problem: East or west, home is best. That's why family reunion, the indispensable necessity of Lunar New Year celebration, is put in such a position.

After the reunion dinner, Little Tommy plays a game with the family. Here is a concise introduction to this game: 

  1. There is a sequence of n non-negative integers p1, p2, ..., pn in the beginning. It is ruled that each integer in this sequence should be non-negative at any time. 
  2. You can select two consecutive positive integers in this sequence, pi and pi + 1 (1 ≤ i < n), and then decrease them by their minimum (i. e. min(pi, pi + 1)), the cost of this operation is equal to min(pi, pi + 1). We call such operation as a descension. 
  3. The game immediately ends when there are no two consecutive positive integers. Your task is to end the game so that the total cost of your operations is as small as possible. 



Obviously, every game ends after at most n - 1 descensions. Please share your solution of this game with the lowest cost.

Input

The first line contains one integer n (1 ≤ n ≤ 3·105).

The second line contains n space-separated integers p1, p2, ..., pn (0 ≤ pi ≤ 109, i = 1, 2, ..., n).

Output

In the first line print one integer as the number of descensions m (0 ≤ m ≤ n - 1).

In the next m lines print the descensions chronologically. More precisely, in each line of the next m lines print one integer i (1 ≤ i < n) representing a descension would operate on pi and pi + 1 such that all the descensions could be utilized from top to bottom.

If there are many possible solutions to reach the minimal cost, print any of them.

Examples

Input

4
2 1 3 1


Output

2
1
3


Input

5
2 2 1 3 1


Output

3
2
1
4

Note

In the first sample, one possible best solution is <image>, of which the cost is 1 + 1 = 2.

In the second sample, one possible best solution is <image>, of which the cost is 1 + 1 + 1 = 3.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using ld = long double;
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (ll i = ll(0); i < ll((ll)v.size()); i++) {
    if (i) os << ",";
    os << v[i];
  }
  os << "]";
  return os;
}
ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}
void printSpace() { printf(" "); }
void printEoln() { printf("\n"); }
void print(ll x, ll suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}
string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}
char* readCharArray() {
  static char buf[3341000];
  static ll bufUsed = 0;
  char* ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}
template <class T, class U>
void chmax(T& a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
void chmin(T& a, U b) {
  if (b < a) a = b;
}
template <class T>
T Sq(const T& t) {
  return t * t;
}
const ll inf = LLONG_MAX / 3;
struct Waf {
  ll cost, last;
  bool operator<(const Waf& rhs) const { return cost < rhs.cost; }
};
void Check(ll ans, vi p, vi mv) {
  ll n = p.size(), cost = 0;
  for (auto x : mv) {
    ll w = min(p[x], p[x + 1]);
    p[x] -= w;
    p[x + 1] -= w;
    cost += w;
  }
  assert(ans == cost);
  for (ll i = ll(0); i < ll(n - 1); i++) assert(p[i] == 0 || p[i + 1] == 0);
}
void Answer(vi mv) {
  print(mv.size());
  for (auto x : mv) print(x + 1);
  exit(0);
}
void CheckAndAnswer(ll ans, vi p, vi mv) {
  ll n = p.size(), cost = 0;
  vi res;
  for (auto x : mv) {
    ll w = min(p[x], p[x + 1]);
    p[x] -= w;
    p[x + 1] -= w;
    cost += w;
    if (w) res.push_back(x);
  }
  assert(ans == cost);
  for (ll i = ll(0); i < ll(n - 1); i++) assert(p[i] == 0 || p[i + 1] == 0);
  Answer(res);
}
const ll Nmax = 300010;
Waf dp[Nmax][2][2];
ll encode(ll a, ll b, ll c) { return (a * 2 + b) * 2 + c; }
void decode(ll x, ll& a, ll& b, ll& c) {
  c = x % 2;
  x /= 2;
  b = x % 2;
  x /= 2;
  a = x;
}
signed main() {
  ll n = read();
  vi p(n);
  for (ll i = ll(0); i < ll(n); i++) p[i] = read();
  for (ll i = ll(0); i < ll(2); i++)
    for (ll j = ll(0); j < ll(2); j++) dp[0][i][j].last = -1;
  Waf z[2][2];
  for (ll i = ll(0); i < ll(2); i++)
    for (ll j = ll(0); j < ll(2); j++) z[i][j] = Waf{inf, 0};
  for (ll x = ll(0); x < ll(n); x++) {
    for (ll i = ll(0); i < ll(2); i++) z[x % 2][i].cost += p[x];
    for (ll i = ll(0); i < ll(2); i++)
      for (ll j = ll(0); j < ll(2); j++) dp[x + 1][i][j].cost = inf;
    for (ll i = ll(0); i < ll(2); i++) {
      ll cost = dp[x][i][0].cost;
      chmin(dp[x + 1][1][1], Waf{cost, encode(x, i, 0)});
    }
    if (x >= 1) {
      ll s = p[x - 1] > p[x], t = p[x - 1] < p[x];
      for (ll i = ll(0); i < ll(2); i++)
        for (ll j = ll(0); j < ll(2); j++) {
          ll cost = dp[x - 1][i][j].cost + min(p[x - 1], p[x]);
          if (j + s <= 1)
            chmin(dp[x + 1][s][t], Waf{cost, encode(x - 1, i, j)});
        }
    }
    if (x >= 2) {
      {
        ll a = p[x - 2], b = p[x - 1], c = p[x], d = 0;
        {
          ll w = min(a, b);
          a -= w;
          b -= w;
          d += w;
        }
        {
          ll w = min(b, c);
          b -= w;
          c -= w;
          d += w;
        }
        ll s = bool(a), t = bool(c);
        for (ll i = ll(0); i < ll(2); i++)
          for (ll j = ll(0); j < ll(2); j++) {
            ll cost = dp[x - 2][i][j].cost + d;
            if (j + s <= 1)
              chmin(dp[x + 1][s][t], Waf{cost, encode(x - 2, i, j)});
          }
      }
      {
        ll a = p[x - 2], b = p[x - 1], c = p[x], d = 0;
        {
          ll w = min(b, c);
          b -= w;
          c -= w;
          d += w;
        }
        {
          ll w = min(a, b);
          a -= w;
          b -= w;
          d += w;
        }
        ll s = bool(a), t = bool(c);
        for (ll i = ll(0); i < ll(2); i++)
          for (ll j = ll(0); j < ll(2); j++) {
            ll cost = dp[x - 2][i][j].cost + d;
            if (j + s <= 1)
              chmin(dp[x + 1][s][t], Waf{cost, encode(x - 2, i, j)});
          }
      }
    }
    if (x >= 3) {
      ll s = p[x - 1] < p[x];
      for (ll i = ll(0); i < ll(2); i++)
        for (ll j = ll(0); j < ll(2); j++) chmin(dp[x + 1][j][s], z[i][j]);
    }
    if (2 <= x) {
      for (ll i = ll(0); i < ll(2); i++)
        for (ll j = ll(0); j < ll(2); j++)
          for (ll k = ll(0); k < ll(2); k++) {
            ll cost = dp[x - 2][i][j].cost;
            for (ll y = ll(x - 2); y < ll(x + 1); y++)
              if (k == y % 2) cost += p[y];
            Waf w = Waf{cost, encode(x - 2, i, j)};
            if (p[x - 2] <= p[x - 1])
              chmin(z[k][0], w);
            else if (j == 0)
              chmin(z[k][1], w);
          }
    }
  }
  ll a = n, b = 0, c = 0;
  for (ll i = ll(0); i < ll(2); i++)
    for (ll j = ll(0); j < ll(2); j++)
      if (dp[n][i][j] < dp[a][b][c]) {
        b = i;
        c = j;
      }
  ll minCost = dp[a][b][c].cost;
  vi mv;
  while (a) {
    ll d, e, f;
    decode(dp[a][b][c].last, d, e, f);
    vi pos;
    for (ll i = ll(d + 1); i < ll(a); i++) pos.push_back(i - 1);
    if (b == 1) reverse(pos.begin(), pos.end());
    if (b == 0 && c == 0) {
      ll tmp = pos.back();
      pos.pop_back();
      pos.insert(pos.begin(), tmp);
    }
    mv.insert(mv.end(), pos.begin(), pos.end());
    assert(f + b <= 1);
    a = d;
    b = e;
    c = f;
  }
  CheckAndAnswer(minCost, p, mv);
}