package main import . "fmt" import . "os" import bf "bufio" func main() { rd:=bf.NewReader(Stdin) var n int Fscan(rd,&n) var ans int64 s:=make([]int64,501,501) t:=make([]int64,501,501) for i:=1;i<=n;i++ { var a int Fscan(rd,&a) s[a]++ t[a]+=int64(i) for k,v:=range t { e:=s[k]*int64(i)-v if k