void Build(int n)
            {
                Array.Sort(pos, (a, b) => (a.X == b.X ? a.Y - b.Y : a.X - b.X));
                int[]         a   = new int[n];
                HashSet <int> set = new HashSet <int>();

                for (int i = 0; i < n; i++)
                {
                    a[i] = pos[i].Y - pos[i].X;
                    set.Add(pos[i].Y - pos[i].X);
                }
                int num = set.Count;

                int[] b     = new int[num];
                int   index = 0;

                foreach (int element in set)
                {
                    b[index++] = element;
                }
                Array.Sort(b);
                BIT bit = new BIT(num + 1);

                for (int i = n - 1; i >= 0; i--)
                {
                    int poss = BinarySearch(b, a[i]) + 1;
                    int j    = bit.query(poss);
                    if (j != -1)
                    {
                        int dis = Math.Abs(pos[i].X - pos[j].X) + Math.Abs(pos[i].Y - pos[j].Y);
                        edges.Add((dis, pos[i].Id, pos[j].Id));