Language: C++

#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

typedef std::vector<int> Poly;
typedef std::pair<int,int> Pair;
typedef unsigned long long ull;
typedef long double ld;
typedef long long ll;

const int maxn = 100000, maxm = 2000, MAX = 1e6 + 5, mod = 1000000;
//template{{{
const long double Pi = 3.14159265358979323846l, Eps = 1e-4;
template <class T> inline bool equal(T x, T y) { return fabs(x - y) < Eps; }
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y, int Mod = mod) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = (ll) ans * x % Mod;
		x = (ll) x * x % Mod, y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int n;
ll d[maxn + 5];
int size[maxn + 5];
std::map<ll, int> id;
std::pair<ll, int> p[maxn + 5];
int fa[maxn + 5];

signed main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	n = read;
	for (int i = 1; i <= n; ++i) {
		p[i].fi = d[i] = read;
		p[i].se = id[d[i]] = i;
		size[i] = 1;
	}

	std::sort(p + 1, p + n + 1);
	for (int i = n; i > 1; --i) {
		ll df = p[i].fi - n + size[p[i].se] * 2;
		fa[p[i].se] = id[df], size[fa[p[i].se]] += size[p[i].se];
		if (!fa[p[i].se] || fa[p[i].se] == p[i].se) return puts("-1"), 0;
	}

	for (int i = 1; i <= n; ++i)
		if (fa[i]) printf("%d %d\n", i, fa[i]);
	return 0;
}


Compiler output:
a.cc:58:3: error: '<unnamed struct> read' redeclared as different kind of entity
   58 | } read; //}}}
      |   ^~~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/14/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
                 from a.cc:1:
/usr/include/unistd.h:371:16: note: previous declaration 'ssize_t read(int, void*, size_t)'
  371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
      |                ^~~~
a.cc: In function 'int main()':
a.cc:74:13: error: invalid conversion from 'ssize_t (*)(int, void*, size_t)' {aka 'long int (*)(int, void*, long unsigned int)'} to 'int' [-fpermissive]
   74 |         n = read;
      |             ^~~~
      |             |
      |             ssize_t (*)(int, void*, size_t) {aka long int (*)(int, void*, long unsigned int)}
a.cc:76:34: error: invalid conversion from 'ssize_t (*)(int, void*, size_t)' {aka 'long int (*)(int, void*, long unsigned int)'} to 'll' {aka 'long long int'} [-fpermissive]
   76 |                 p[i].fi = d[i] = read;
      |                                  ^~~~
      |                                  |
      |                                  ssize_t (*)(int, void*, size_t) {aka long int (*)(int, void*, long unsigned int)}