#include <bits/stdc++.h>   namespace IO {   template <typename Tp>   inline Tp input() {     Tp x = 0, y = 1;     char c = getchar();     while ((c <  0  ||  9  < c) && c != EOF) {       if (c ==  - ) y = -1;       c = getchar();     }     if (c == EOF) return 0;     while ( 0  <= c && c <=  9 ) x = x * 10 + c -  0 , c = getchar();     return x *= y;   }   template <typename Tp>   inline void read(Tp &x) {     x = input<Tp>();   }   };  // namespace IO   using namespace IO;   namespace modular {   const int MOD = 1000000007;   inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }   inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }   inline int mul(int x, int y) { return 1LL * x * y % MOD; }   inline int qpow(int x, int y) {     int ans = 1;     for (; y; y >>= 1, x = mul(x, x))       if (y & 1) ans = mul(ans, x);     return ans;   }   };  // namespace modular   int N, top, tot;   int a[2007], b[2007], c[3];   std::pair<int, int> ans[2007 * 2007];   bool cmp(int x, int y) { return a[x] < a[y]; }   int main() {     srand(0x66ccf);     read(N);     for (int i = 1; i <= N; ++i) read(a[i]);     top = N;     for (int i = 1; i <= top; ++i) b[i] = i;     std::sort(b + 1, b + N + 1, cmp);     std::reverse(b + 1, b + N + 1);     while (top && !a[b[top]]) top--;     if (top < 2) return puts( -1 ), 0;     while (top > 2) {       for (int i = 0; i <= 2; ++i) {         c[i] = rand() % (top - i) + i + 1;         std::swap(b[i + 1], b[c[i]]);         c[i] = b[i + 1];       }       std::sort(c, c + 3, cmp);       int k = a[c[1]] / a[c[0]], mx = 0;       for (int i = 0; i <= 21; ++i)         if (k >> i & 1) mx = i;       for (int i = 0; i <= 2; ++i) b[i + 1] = c[i];       for (int i = 0; i <= mx; ++i) {         if (k >> i & 1) {           ans[++tot] = std::pair<int, int>(c[0], c[1]);           a[c[1]] -= a[c[0]];           a[c[0]] *= 2;         } else {           ans[++tot] = std::pair<int, int>(c[0], c[2]);           a[c[2]] -= a[c[0]];           a[c[0]] *= 2;         }       }       if (!a[c[1]]) {         std::swap(b[top], b[2]);         top--;       }     }     printf( %d n , tot);     for (int i = 1; i <= tot; ++i) printf( %d %d n , ans[i].first, ans[i].second);     return 0;   }   