#include using namespace std; #include using namespace atcoder; #define rep(i, n) for(int i=0;i<(n);++i) #define rep1(i, n) for(int i=1;i<=(n);i++) #define ll long long using mint = modint998244353; using P = pair; using lb = long double; using T = tuple; #ifdef LOCAL # include # define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else # define dbg(...) (static_cast(0)) #endif int main() { int n; cin >> n; vector a(n); rep(i,n) cin >> a[i]; vector vs; rep(i,n){ if(a[i]==0 || a[i]==1){ cout << 0 << endl; cout << i + 1 << " " << (i+1)%n+1 << endl; for(int j=n-1;j>=2;j--){ cout << j << " " << 1 << endl; } return 0; } } rep(i,n) if(a[i]%2==0) vs.push_back(i); if(vs.size()>=2){ cout << 0 << endl; cout << vs[0] +1 << " " << vs[1] + 1 << endl; for(int j=n-1;j>=2;j--){ cout << j << " " << 1 << endl; } return 0; } vector odd; rep(i,n) if(a[i]%2) odd.push_back(i); if(odd.size()>=4){ cout << 0 << endl; cout << odd[0]+1 << " " << odd[1] + 1 << endl; cout << odd[2] + 1 -2 << " " << odd[3] + 1 -2 << endl; for(int j=n-2;j>=2;j--){ cout << j << " " << 1 << endl; } return 0; } if(odd.size()>=2 && vs.size()==1){ cout << 0 << endl; cout << odd[0] + 1 << " " << odd[1] + 1 << endl; vector v; rep(i,n){ if(i==odd[0] || i==odd[1]){ continue; } v.push_back(a[i]); } rep(i,n-2){ if(v[i]%2==0) { cout << i + 1 << " " << n-1 << endl; break; } } for(int j=n-2;j>=2;j--){ cout << j << " " << 1 << endl; } return 0; } if(n==2){ cout << a[0]*a[1] - a[0] - a[1] + 1 << endl; cout << 1 << " " << 2 << endl; } return 0; }