using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; using System.Threading; using System.Runtime.CompilerServices; using System.Diagnostics; static class Program{ const int mod=(int)1e9+7; static void Main(){ Sc sc=new Sc(); var s=sc.Ia; Uf uf1=new Uf(s[0]+1),uf2=new Uf(s[0]+1); for(int i = 0;i(); long ans=0; for(int i = 1;i<=s[0];i++) { var t=uf1.Root(i)+" "+uf2.Root(i); if(!hs.Contains(t)){ ans+=uf1.Size(i)*(long)uf2.Size(i); hs.Add(t); } } Console.WriteLine("{0}",ans-s[0]); } } public class Uf{ private int[] arr,hi; public int all; public Uf(int n){ arr=new int[n]; hi=new int[n]; all=n; for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i