- https://codeforces.com/gym/105104/problem/C
const int N = 1e6 + 10;int T, n, x;
ull v[N];int main() {mt19937_64 rng(random_device{}()); // 注意这种生成随机数的方法!!!F(i, 0, N - 10)v[i] = rng();for (R(T); T --; ) {R(n);map <ull, int> H; H[0] = 1;long long Ans = 0;ull s = 0;F(i, 1, n) { R(x), s ^= v[x];Ans = Ans + i - H[s];H[s] ++;}W(Ans), putc('\n');}
}