#include<cstdio>
#include<memory.h>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<string.h>
#include<queue>
int n, arr[200000], temp[200000] = {}, ans = 0;
using namespace std;
int main()
{
	bool chk[200000] = {}, chk2[200000] = {};
	scanf("%d", &n);
	for (int i = 0; i < n; i++)scanf("%d", &arr[i]);
	temp[n - 1] = 1;
	chk[arr[n - 1]] = true;
	for (int i = n-2; i >= 0; i--) {
		if (chk[arr[i]]) {
			temp[i] = temp[i + 1];
		}
		else {
			temp[i] = temp[i + 1] + 1;
			chk[arr[i]] = true;
		}
	}
	for (int i = 0; i < n-1; i++) {
		if (chk2[arr[i]])continue;
		else {
			chk2[arr[i]] = true;
			ans += temp[i + 1];
		}
	}
	printf("%d", ans);
	return 0;
}


#include<cstdio>
#include<memory.h>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<string.h>
#include<queue>
int n, arr[200000],temp[200000];
using namespace std;
int main()
{
	long long ans = 0;
	bool chk[200000] = {}, chk2[200000] = {};
	scanf("%d", &n);
	for (int i = 0; i < n; i++)scanf("%d", &arr[i]);
	temp[n - 1] = 1;
	chk[arr[n - 1]] = true;
	for (int i = n-2; i >= 0; i--) {
		if (chk[arr[i]]) {
			temp[i] = temp[i + 1];
		}
		else {
			temp[i] = temp[i + 1] + 1;
			chk[arr[i]] = true;
		}
	}
	for (int i = 0; i < n-1; i++) {
		if (chk2[arr[i]])continue;
		else {
			chk2[arr[i]] = true;
			ans += temp[i + 1];
		}
	}
	cout << ans << endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <queue>
#include <cstring>
#include <fstream>
#define ll long long int
using namespace std;
const double _pi = acos(-1.0);
int ar[100010];
int ar2[100010];
int ar3[100010];
int main()
{
    //freopen("in.txt", "r", stdin);
	int n, r = 0;
	scanf("%d", &n);
	ll res = 0;
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &ar[i]);
		ar2[ar[i]]++;
		if(ar3[ar[i]] == 0)
		{
			ar3[ar[i]] = 1;
			r++;
		}
	}
	for(int i = 0; i < n; i++)
	{
		ar2[ar[i]]--;
		if(ar2[ar[i]] == 0) r--;
		if(ar3[ar[i]] == 1)
		{
			res += r;
			ar3[ar[i]] = 0;
		}
	}
	printf("%I64d\n", res);
    return 0;
}


#include <iostream>
#include <cstdio>

using namespace std;

int n;
int a[100001];
int ans[100001];
bool v1[100001]={false};
bool v2[100001]={false};

int main(){
    int i,j;
	cin>>n;
    for(i=1;i<=n;i++)
     cin>>a[i];
    int sum=0;
    for(i=n;i>=1;i--)
    {
    	ans[i]=sum;
    	if(v1[a[i]])
    	continue;
    	sum++;
    	v1[a[i]]=true;
	}
	sum=0;
	for(i=1;i<=n;i++){
	//	cout<<ans[i]<<endl;
	if(!v2[a[i]])
	sum+=ans[i],v2[a[i]]=true;
	}
	cout<<sum;
}


#include <iostream>
#include <cstdio>

using namespace std;

int n;
int a[100010];
int ans[100010];
bool v1[100010]={false};
bool v2[100010]={false};

int main(){
    int i,j;
	cin>>n;
    for(i=1;i<=n;i++)
     cin>>a[i];
    int sum=0;
    for(i=n;i>=1;i--)
    {
    	ans[i]=sum;
    	if(v1[a[i]])
    	continue;
    	sum++;
    	v1[a[i]]=true;
	}
	sum=0;
	for(i=1;i<=n;i++){
	//	cout<<ans[i]<<endl;
	if(!v2[a[i]])
	sum+=ans[i],v2[a[i]]=true;
	}
	cout<<sum;
}


#include<iostream>
using namespace std;
int main(){
	//��������
	int n,i,j,left=0,right=0;
	int N[100001]={0},a[100001],M[100001]={0};
	cin>>n;
	for(i=0;i<n;i++)
	 cin>>a[i];
	//���ĳ���
	//��������߿�ʼͳ�Ʋ��ظ��ĸ��� ,���ֲ��������ǿռ任ʱ��
	for(i=0;i<n;i++)
	{
		N[a[i]]++;
		if(N[a[i]]>=2)break;
		left++;
	}
	//�������ұ߿�ʼͳ�Ʋ��ظ��ĸ���
	for(i=n-1;i>=0;i--)
	{
		M[a[i]]++;
		if(M[a[i]]>=2)break;
		right++;
	}
	//��ͳ�ƵĽ���������õó����
	if(left+right<=n)
	{
		cout<<left*right;
		return 0;
	}
	if(left+right>n)
	{
		int num=(right+left-n);
		int a1=(left-1);
		cout<<num*a1-num*(num-1)/2+(n-right)*right;
	}

}


#include <iostream>
#include <cstdio>

using namespace std;

int n;
int a[100010];
int ans[100010];
bool v1[100010]={false};
bool v2[100010]={false};

int main(){
    int i,j;
	cin>>n;
    for(i=1;i<=n;i++)
     cin>>a[i];
   long long int sum=0;
    for(i=n;i>=1;i--)
    {
    	ans[i]=sum;
    	if(v1[a[i]])
    	continue;
    	sum++;
    	v1[a[i]]=true;
	}
	sum=0;
	for(i=1;i<=n;i++){
	//	cout<<ans[i]<<endl;
	if(!v2[a[i]])
	sum+=ans[i],v2[a[i]]=true;
	}
	cout<<sum;
}


#include<iostream>
using namespace std;
int main(){
	//��������
	int n,i,j,left=0,right=0;
	int N[100001]={0},a[100001],M[100001]={0};
	cin>>n;
	for(i=0;i<n;i++)
	 cin>>a[i];
	//���ĳ���
	//��������߿�ʼͳ�Ʋ��ظ��ĸ��� ,���ֲ��������ǿռ任ʱ��
	for(i=0;i<n;i++)
	{
		N[a[i]]++;
		if(N[a[i]]>=2)break;
		left++;
	}
	//�������ұ߿�ʼͳ�Ʋ��ظ��ĸ���
	for(i=n-1;i>=0;i--)
	{
		M[a[i]]++;
		if(M[a[i]]>=2)break;
		right++;
	}
	//��ͳ�ƵĽ���������õó����
	if(left+right<=n)
	{
		cout<<left*right;
		return 0;
	}
	if(left+right>n)
	{
		int num=(right+left-n);
		int a1=(right-1);
		cout<<num*a1-num*(num-1)/2+(n-right)*right;
	}

}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int deal[999999];
int visl[999999];
int visr[999999];
int viss[999999];
int n;
int main() {
    while(cin>>n)
    {
        memset(visl,true,sizeof(visl));
        memset(visr,true,sizeof(visr));
        memset(viss,0,sizeof(viss));
        int z=0;
        for(int i=0;i<n;i++)
        {
            int a;
            cin>>a;
            if(viss[a]<2)
            {
                deal[z++]=a;
                viss[a]++;
            }

        }
        //cout<<z<<endl;
        int num=0;
        for(int i=0;i<z;i++)
        {
            //cout<<deal[i]<<endl;
            if(visl[deal[i]])
            {
                memset(visr,true, sizeof(visr));
                for(int j=i+1;j<z;j++)
                {
                    if(visr[deal[j]])
                    {
                        num++;
                        //cout<<num<<' '<<deal[j]<<endl;
                        visr[deal[j]]=false;
                    }
                }
                visl[deal[i]]=false;
            }
        }
        cout<<num<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
using namespace std;
typedef long long ll;
ll deal[999999];
ll visl[999999];
ll b[999999];
int n;
int main() {
    while(cin>>n)
    {
        ll num=0;
        memset(visl,true,sizeof(visl));
        memset(b,0, sizeof(b));
        for(int i=0;i<n;i++) {
            cin>>deal[i];
        }
        set<ll>s;
        for(int i=n-1;i>0;i--)
        {
            s.insert(deal[i]);
            b[i]=s.size();
        }
        for(int i=0;i<n;i++)
        {
            if(visl[deal[i]])
            {
                num+=b[i+1];
                visl[deal[i]]=false;
            }
        }
        cout<<num<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int deal[999999];
int visl[999999];
int visr[999999];
int n;
int main() {
    while(cin>>n)
    {
        memset(visl,true,sizeof(visl));
        memset(visr,true,sizeof(visr));
        int z=1;
        for(int i=0;i<n;i++)
        {
            cin>>deal[i];
        }
        int num=0;
        for(int i=0;i<n;i++)
        {
            if(visl[deal[i]])
            {
                memset(visr,true, sizeof(visr));
                for(int j=i+1;j<n;j++)
                {
                    if(visr[deal[j]])
                    {
                        num++;
                        //cout<<num<<' '<<deal[j]<<endl;
                        visr[deal[j]]=false;
                    }
                }
                visl[deal[i]]=false;
            }
        }
        cout<<num<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
using namespace std;
int deal[999999];
int visl[999999];
int b[999999];
int n;
int main() {
    while(cin>>n)
    {
        int num=0;
        memset(visl,true,sizeof(visl));
        memset(b,0, sizeof(b));
        for(int i=0;i<n;i++) {
            cin>>deal[i];
        }
        set<int>s;
        for(int i=n-1;i>0;i--)
        {
            s.insert(deal[i]);
            b[i]=s.size();
        }
        for(int i=0;i<n;i++)
        {
            if(visl[deal[i]])
            {
                num+=b[i+1];
                visl[deal[i]]=false;
            }
        }
        cout<<num<<endl;
    }
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include<map>
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	long long n,ans=0; cin >> n;
	vector<int>a(n);
	map<int, int>b, c;
	for (int i = 0; i < n; i++) {
		int u; cin >> u;
		a.push_back(u);
		if (!b.count(u))
			b[u] = i;
		c[u] = i;
	}
	vector<int>b1, c1;
	for (auto it = b.begin(); it != b.end(); ++it) {
		b1.push_back(it->second);
	}
	for (auto it = c.begin(); it != c.end(); ++it) {
		c1.push_back(it->second);
	}
	sort(b1.begin(), b1.end());
	sort(c1.begin(), c1.end());
	int i = 0, j = 0;
	while (i < b1.size()) {
		while (j < c1.size() && c1[j] <= b1[i])j++;
		if (j != c1.size()) {
			ans += c1.size() - j;
		}
		i++;
	}
	cout << ans;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include<map>
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n,ans=0; cin >> n;
	vector<int>a(n);
	map<int, int>b, c;
	for (int i = 0; i < n; i++) {
		int u; cin >> u;
		a.push_back(u);
		if (!b.count(u))
			b[u] = i;
		c[u] = i;
	}
	vector<int>b1, c1;
	for (auto it = b.begin(); it != b.end(); ++it) {
		b1.push_back(it->second);
	}
	for (auto it = c.begin(); it != c.end(); ++it) {
		c1.push_back(it->second);
	}
	sort(b1.begin(), b1.end());
	sort(c1.begin(), c1.end());
	int i = 0, j = 0;
	while (i < b1.size()) {
		while (j < c1.size() && c1[j] <= b1[i])j++;
		if (j != c1.size()) {
			ans += c1.size() - j;
		}
		i++;
	}
	cout << ans;
}


#include <iostream>
#include<algorithm>
#include<string>
#include<map>
#include <iterator>
#include<iomanip>
#include<vector>
#include<cmath>
#include <cstdio>
#include<queue>
#include<stack>
#include<list>
#include<stdio.h>
#include<set>
#include <functional>

#define mod 1000000007
#define mod2 30000000
#define pa(a,b) make_pair(a,b)
#define f first
#define s second
#define pb(a)  push_back(a)
#define all(a) a.begin() , a.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define LL  long long int
#define oo 1e9
#define pi 3.14159265359
#define eps  1e-9

LL maxx(LL a , LL b){ return a>b ?  a : b ;}
LL minn(LL a , LL b){ return a>b ?  b : a ;}

using namespace std;
int dx[] = {1 , 1 ,1 , 0 , 0  , -1 , -1  , -1  , 0 };
int dy[] = { -1 , 0  , 1 , 1 , -1 , 0 , 1 , -1 , 0 };
void boostIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
LL gcd(LL a, LL b) {
    return b == 0 ? a : gcd(b, a % b);
}
LL lcm(LL a , LL b )
{
    return (a*b)/gcd(a , b);
}
LL poww(LL base, LL exp){
  base %= mod;
  LL result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % mod;
    base = (base * base) % mod;
    exp >>= 1;
  }
  return result;
}
bool vis[100100][2]; vector<int>a ;
int suf[200200] ;
int main()
{
    int n ; cin >> n ;

    for(int i = 0 ; i < n ; i++){
        int x; cin >> x ;
        a.pb(x) ;
    }

    for(int i = n - 1 ; i >= 0 ; i--){
        suf[i] = suf[i + 1] + !(vis[a[i]][0]) ;
        vis[a[i]][0]  = 1 ;
    }

    LL ans = 0 ;

    for(int i = 0 ; i < n ; i++){
        if(vis[a[i]][1])
            continue ;
        vis[a[i]][1] = 1 ;
        ans = ans + suf[i + 1] ;
    }

    cout << ans << endl ;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long double ld;
typedef long long ll;	// Use "%I64d" as placeholder with printf and scanf.
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef complex<double> cd;
typedef vector<cd> vcd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef priority_queue<ll, vector<ll>, greater<ll>> min_heap_ll;
typedef priority_queue<ll, vector<ll>, less<ll>> max_heap_ll;

#define pi 3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define f(i, n) for(ll i=0; i<n; ++i)
#define fi(i, n, j) for(ll i=j; i<n; ++i)
#define mp make_pair
#define all(container) container.begin(), container.end()
#define allr(container) container.rbegin(), container.rend()
#define tr(container, it) for (decltype(container.begin()) it = container.begin(); it != container.end(); it++)
#define trr(container, it) for (decltype(container.rbegin()) it = container.rbegin(); it != container.rend(); it++)
#define dist(a, b) sqrtl(powl(ld(a.first - b.first), 2) + powl(ld(a.second - b.second), 2))

// useful functions
ll gcd(ll a, ll b)
{
	return b ? gcd(b, a % b) : a;
}

ll my_exp(ll a, ll b, ll MOD = numeric_limits<ll>::max())
{
	a %= MOD;
	return b ? (((b % 2 == 1 ? a : 1) * my_exp(a * a, b / 2, MOD)) % MOD) : 1;
}

bool is_prime(ll n)	// O(sqrt(n)) implementation check for 0 and 1 separately
{
	if (n != 2 && n % 2 == 0) return false;
	else { for (ll i = 3; (i*i) <= n; i += 2) if (n%i == 0) return false; return true; }
}

// Program global variables

// Program classes and structs

// Program functions

int main()
{
#ifdef _CODE_SOURCE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	double start_time = clock();
#endif
	// Program Code
	ll n; cin >> n;
	vll a(n); f(i, n) cin >> a[i];
	set<ll> unique;
	vll uni_arr(n);
	uni_arr[n - 1] = 0;
	for (ll i = n - 2; i >= 0; --i)
	{
		uni_arr[i] = uni_arr[i + 1];
		if (unique.find(a[i + 1]) == unique.end())
		{
			unique.insert(a[i + 1]);
			uni_arr[i]++;
		}
	}
	unique.clear();
	ll ans = 0;
	f(i, n)
	{
		if (unique.find(a[i]) == unique.end())
		{
			ans += uni_arr[i];
			unique.insert(a[i]);
		}
	}
	cout << ans;

	// Program Code Ends
#ifdef _CODE_SOURCE
	double end_time = clock();
	printf("\nTime = %.3f seconds\n", (end_time - start_time) / CLOCKS_PER_SEC);
#endif
	return(0);
}


#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, cnt = 0;
	cin >> n;
	vector<int> a(n), cntr(100001);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		cnt += !cntr[a[i]];
		++cntr[a[i]];
	}
	vector<char> used(100001);
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		--cntr[a[i]];
		cnt -= !cntr[a[i]];
		if (!used[a[i]])
			ans += cnt;
		used[a[i]] = 1;
	}
	cout << ans;
	return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;

int main(){

 int n,len=100001;
 scanf("%d",&n);

 int *a=new int [n];
 int *s=new int [n];
 int *sup=new int [len];

 for(int i=0;i<len;i++)
    sup[i]=0;

 for(int i=0;i<n;i++){
    s[i]=0;
    scanf("%d",&a[i]);
    sup[a[i]]++;
    if(i!=0 && sup[ a[i] ]==1 )s[i]=s[i-1]+1;else if(i!=0) s[i]=s[i-1];
    if(i==0)s[i]=1;
 }

 /*for(int i=0;i<n;i++)
    printf("%d ",s[i]);//*/

 unsigned __int64 ans=0;

 int *sp=new int [len];

 for(int i=0;i<len;i++)
    sp[i]=0;

 for(int i=n-1;i>0;i--){
   if( sp[a[i]]==0 )  ans+=sup[ a[i] ]>1? s[i]:s[i]-1 ;
   sp[ a[i] ]=1;
 }
 cout<<ans;
return 0;
}


#include <cstdio>

int main(){

 int n,len=100001;
 scanf("%d",&n);

 int *a=new int [n];
 int *s=new int [n];
 int *sup=new int [len];

 for(int i=0;i<len;i++)
    sup[i]=0;

 for(int i=0;i<n;i++){
    s[i]=0;
    scanf("%d",&a[i]);
    sup[a[i]]++;
    if(i!=0 && sup[ a[i] ]==1 )s[i]=s[i-1]+1;else if(i!=0) s[i]=s[i-1];
    if(i==0)s[i]=1;
 }

 /*for(int i=0;i<n;i++)
    printf("%d ",s[i]);//*/

 int ans=0;

 int *sp=new int [len];

 for(int i=0;i<len;i++)
    sp[i]=0;

 for(int i=n-1;i>0;i--){
   if( sp[a[i]]==0 )  ans+=sup[ a[i] ]>1? s[i]:s[i]-1 ;
   sp[ a[i] ]=1;
 }
 printf("%d",ans);
return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <queue>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <float.h>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vp;
typedef vector<string> vs;
typedef set<int> si;
typedef map<int, int> mi;
typedef multimap<int, int> mmi;
typedef map<int, vi> mivi;

const int MAX = 100000;

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	vi a(n);

	vi first(MAX + 1, -1);
	vi last(MAX + 1, -1);

	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		last[a[i]] = i;
	}
	for (int i = n - 1; i >= 0; --i)
		first[a[i]] = i;

	vi b;
	for (int i = 0; i < n; ++i)
	{
		if (i == first[a[i]] || i == last[a[i]])
			b.push_back(a[i]);
	}

	n = b.size();

	first.assign(MAX + 1, -1);

	for (int i = n - 1; i >= 0; --i)
		first[b[i]] = i;
	for (int i = 0; i < n; ++i)
		last[b[i]] = i;

	ll res = 0;

	vi uniques(n);
	uniques[n - 1] = 1;
	for (int i = n - 2; i >= 0; --i)
	{
		uniques[i] = uniques[i + 1];
		if (first[b[i]] == last[b[i]] || i != first[b[i]])
			++uniques[i];
	}

	for (int i = 0; i < n - 1; ++i)
	{
		if (i == first[b[i]])
		{
			res += uniques[i + 1];
		}
	}

	cout << res << endl;

	return 0;
}


/*
　        ┏┓　　　┏┓
　　　　┏┛┻━━━┻┗┓
　　　　┃　　　　　　　┃
　　　　┃　　　━　　　┃
　　　　┃　┳┛　┗┳　┃
　　　　┃　　　　　　　┃
　　　　┃　　　┻　　　┃
　　　　┗━┓　    ┏━┛
　　　　　　┃　一  ┃
　　　　　　┃　发  ┃
　　　　　　┃　 A  ┃
　　　　　　┃　 C  ┃
　　┏━━━┛　  　┃
　┏┫　　　　　  　┃
　┗┓　***　     　┃
　　┗┓┏┳━┓┏┏┛
　　　┣┣┃　┣┣┃
　　　┗┻┛　┗┻┛

*/
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#define LL long long
#define maxn 100005
using namespace std;
int a[maxn],b[maxn];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    set<int>s1;
    b[n]=0;
    for(int i=n-1;i>=0;i--)
    {
        if(s1.count(a[i])==0)
            b[i]=b[i+1]+1;
        else
            b[i]=b[i+1];
        s1.insert(a[i]);
    }
    set<int>s2;
    LL sum=0;
    for(int i=0;i<n-1;i++)
    {
        if(s2.count(a[i])==0)
            sum+=b[i+1];
        s2.insert(a[i]);
    }
    cout<<sum<<endl;
}


#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <queue>
#include <stack>
#include <string.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
#define pb push_back

void solve(){
    int n, m;
    cin >> n;
    vector<int> arr(n);
    set<int> s;
    vector<int> dp(n);
    dp[n - 1] = 1;
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
    }
    s.insert(arr[n - 1]);
    for(int i = n - 2; i >= 0; --i){
        if(!s.count(arr[i])){
            dp[i] = dp[i + 1] + 1;
            s.insert(arr[i]);
        }
        else
            dp[i] = dp[i + 1];

    }
    ll res = 0;
    s.clear();
    for(int i = 0; i < n - 1; ++ i){
        if(!s.count(arr[i])){
            res += dp[i + 1];
            s.insert(arr[i]);
        }
    }
    cout << res;

}
int main() {
	ios_base::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(9);
	solve();
	return 0;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include <map>
using namespace std;
set<long long> otels;
int n, q;
long long ans = 0;
vector<long long> nm;
string s;
map<int, int> mp;
bool cmp(int x, int y)
{
	return x > y;
}

int main()
{
	cin >> n;
	nm.resize(n);
	for (int i = 0; i < n; i++)
	{
		cin >> nm[i];
		if (mp.count(nm[i]) != 0)
			mp[nm[i]]++;
		else
			mp.insert(make_pair(nm[i], 1));
	}
	for (int i = 0; i < n; i++)
	{
		mp[nm[i]]--;
		if (mp[nm[i]] == 0)
			mp.erase(mp.find(nm[i]));
		if(otels.count(nm[i])==0)
		ans += mp.size();
		otels.insert(nm[i]);

	}
	cout << ans;
	system("pause");
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include <map>
using namespace std;
set<long long> otels;
int n, q;
long long ans = 0;
vector<long long> nm;
string s;
map<int, int> mp;
bool cmp(int x, int y)
{
	return x > y;
}

int main()
{
	cin >> n;
	nm.resize(n);
	for (int i = 0; i < n; i++)
	{
		cin >> nm[i];
		if (mp.count(nm[i]) != 0)
			mp[nm[i]]++;
		else
			mp.insert(make_pair(nm[i], 1));
	}
	for (int i = 0; i < n; i++)
	{
		mp[nm[i]]--;
		if (mp[nm[i]] == 0)
			mp.erase(mp.find(nm[i]));
		if(otels.count(nm[i])==0)
		ans += mp.size();
		otels.insert(nm[i]);

	}
	cout << ans;
	//system("pause");
}


#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std;

int inp_data[100001];
int first_right_in[100001];

int n;
set<int> numb_was;
set<int> an_numb;

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> inp_data[i];
	}

	for (int i = n - 1; i >= 0; i--)
	{
		if (numb_was.find(inp_data[i]) == numb_was.end())
		{
			first_right_in[i] ++;
			numb_was.insert(inp_data[i]);
		}
	}

	int val = 0;
	long long answer = numb_was.size() * numb_was.size();

	for (int i = 0; i < n; i++)
	{
		val += first_right_in[i];
		if (an_numb.find(inp_data[i]) == an_numb.end())
		{
			answer -= val;
			an_numb.insert(inp_data[i]);
		}
	}

	cout << answer;

	return 0;
}


#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std;

int inp_data[100001];
int first_right_in[100001];

int n;
set<int> numb_was;
set<int> an_numb;

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> inp_data[i];
	}

	for (int i = n - 1; i >= 0; i--)
	{
		if (numb_was.find(inp_data[i]) == numb_was.end())
		{
			first_right_in[i] ++;
			numb_was.insert(inp_data[i]);
		}
	}

	int val = 0;
	long long answer = (long long)numb_was.size() * numb_was.size();

	for (int i = 0; i < n; i++)
	{
		val += first_right_in[i];
		if (an_numb.find(inp_data[i]) == an_numb.end())
		{
			answer -= val;
			an_numb.insert(inp_data[i]);
		}
	}

	cout << answer;

	return 0;
}


#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<tuple>
#include<set>
#include<utility>
#include<map>
#include <unordered_map>
#include <bitset>
using namespace std;
typedef long long ll;
int A[100004], B[100004], S[100004];
int main() {
	int i, n, a;
	cin >> n;
	for (i = 0; i < n; i++) cin >> A[i];
	if (n == 1) {
		cout << 0; return 0;
	}
	B[n - 1] = 1;
	S[A[n - 1]] = 1;
	for (i = n - 2; i >= 0; i--) {
		a = A[i];
		B[i] = B[i + 1];
		if (S[a]) continue;
		S[a] = 1;
		B[i]++;
	}
	for (i = 0; i <= 100000; i++) S[i] = 0;
	ll ans = 0;
	for (i = 0; i < n - 1; i++) {
		a = A[i];
		if (S[a]) continue;
		ans += B[i + 1];
		S[a] = 1;
	}
	cout << ans;
}


#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std ;
const int maxn = 1e5 + 20 ;
int a[maxn] ;
int vis[maxn] ;
int vis1[maxn] ;
int dp[maxn] ;
int n ;
int main()
{
    while(scanf("%d",&n) != EOF)
    {
        long long ans = 0 ;
    	dp[n + 1] = 0 ;
        memset(dp,0,sizeof(dp)) ;
        memset(vis,0,sizeof(vis)) ;
        memset(vis1,0,sizeof(vis1)) ;
    	for(int i = 1 ; i <= n ; i ++)
    	{
    		scanf("%d",&a[i]) ;
		}
		for(int i = n ; i >= 1 ; i --)
		{
			if(vis[a[i]]) {
    		    dp[i] = dp[i + 1] ;
			}
			else {
				dp[i] = dp[i + 1] + 1 ;
				vis[a[i]] = 1 ;
			}
		}

    	for(int i = 1 ; i <= n ; i ++)
    	{
    		if(!vis1[a[i]]){
    			vis1[a[i]] = 1 ;
    			ans += dp[i + 1] ;
			}
		}
    	printf("%I64d\n",ans) ;
	}
	return 0 ;
}


#include <iostream>
#include <string.h>
#include <limits.h>

using namespace std;

static char _buf[1 << 16];
int _pos = 1;
int _cap = 1;

inline char nextChar()
{
	if (_cap == 0) return 0;
	if (_pos == _cap)
	{
		_cap = (int)fread(_buf, 1, 1 << 16, stdin);
		if (_cap == 0) return 0;
		_pos = 0;
	}
	return _buf[_pos++];
}

template <class T> T nextInt()
{
	char c = nextChar();
	while (isspace(c)) c = nextChar();
	int sign = 1;
	if (c == '-')
	{
		sign = -1;
		c = nextChar();
	}
	T res = 0;
	while (isdigit(c))
	{
		res = res * 10 + c - '0';
		c = nextChar();
	}
	return res * sign;
}

int a[100000];
int m[100001];
int u[100001];
int s = 0;

int main()
{

	int n = nextInt<int>();
	for (int i = 0; i < n; i++)
		a[i] = nextInt<int>();
	for (int i = n - 1; i > 0; i--)
		if (++m[a[i]] == 1) ++s;

	long long res = 0;
	for (int i = 0; i < n - 1; i++)
	{
		if (!u[a[i]])
		{
			u[a[i]] = 1;
#ifndef ONLINE_JUDGE
			printf("%d: %d, +%d\n", i, a[i], s);
#endif // !ONLINE_JUDGE

			res += s;
		}
		if (--m[a[i + 1]] == 0) --s;
	}
	cout << res << endl;

	return 0;
}


#include<set>
#include<stdio.h>
using namespace std;
int main()
{int n,rec[100005]={0},num[100005],a,ans=0;
set<int> se;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{num[i]=se.size();
scanf("%d",&a);
se.insert(a);
rec[a]=i;
}
for(int i=100000;i>0;i--)
	if(rec[i]!=0)
		ans+=num[rec[i]];
printf("%d",ans);}


#include<set>
#include<stdio.h>
using namespace std;
int main()
{int n,s[100005]={0},e[100005]={0},a,ans=0;
set<int> se;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{scanf("%d",&a);
if(s[a]==0)
	s[a]=i;
e[a]=i;
se.insert(a);}
set<int>::iterator it,iter;
for(it=se.begin();it!=se.end();it++)
	for(iter=se.begin();iter!=se.end();iter++)
		if(s[*it]<e[*iter])
			ans++;
printf("%d",ans);}


#include<set>
#include<stdio.h>
using namespace std;
int main()
{int n,s[100005]={0},e[100005]={0},pos[100005],a,ans=0;
set<int> se;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{scanf("%d",&a);
if(s[a]==0)
	s[a]=i;
e[a]=i;
se.insert(a);}
set<int>::iterator it;
int now=0;
for(it=se.begin();it!=se.end();it++)
{pos[now]=*it;now++;}
for(int i=0;i<now;i++)
	for(int j=0;j<now;j++)
		if(s[pos[i]]<e[pos[j]])
			ans++;
printf("%d",ans);}


#include<set>
#include<stdio.h>
using namespace std;
int main()
{int n,rec[100005]={0},num[100005],a;long long ans=0;
set<int> se;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{num[i]=se.size();
scanf("%d",&a);
se.insert(a);
rec[a]=i;
}
for(int i=100000;i>0;i--)
	if(rec[i]!=0)
		ans+=num[rec[i]];
printf("%I64d",ans);}


#define _USE_MATH_DEFINES
#include <assert.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long     ll;
typedef unsigned int  UInt;
#define ALL(a)          (a).begin(), (a).end()
#define FOR(i,a,b)      for(int i = a;   i <  (int)(b); ++i)
#define FOR_REV(i,a,b)  for(int i = b-1; i >= (int)(a); --i)
#define FOR_EACH(it,a)  for(remove_reference<decltype(a)>::type::iterator it = (a).begin(); it != (a).end(); ++it)
#define FOR_EACH_REV(it,a) for(remove_reference<decltype(a)>::type::reverse_iterator it = (a).rbegin(); it != (a).rend(); ++it)
#define FOR_EACH_CONST(it,a) for(remove_reference<decltype(a)>::type::const_iterator it = (a).begin(); it != (a).end(); ++it)
#define FOR_EACH_CONST_REV(it,a) for(remove_reference<decltype(a)>::type::const_reverse_iterator it = (a).rbegin(); it != (a).rend(); ++it)
template<class T> inline T   sqr(T v)  { return v * v; }
template<class T> inline int sign(T v) { return v == 0 ? 0 : (v > 0 ? 1 : -1); }
template<class T> inline int get_bit(T v, int bit_index) { return (v >> bit_index) & 1; } //return {0,1}
template<class T> inline T   gcd(T a, T b) { while(b) { T t = b; b   = a % b; a   = t; } return a; }
#define IN_INT(a)            int a;       is >> a;
#define IN_INT2(a,b)         int a,b;     is >> a >> b;
#define IN_INT3(a,b,c)       int a,b,c;   is >> a >> b >> c;
#define IN_INT4(a,b,c,d)     int a,b,c,d; is >> a >> b >> c >> d;
#define IN_LL(a)             ll a;        is >> a;
#define IN_LL2(a,b)          ll a,b;      is >> a >> b;
#define IN_LL3(a,b,c)        ll a,b,c;    is >> a >> b >> c;
#define IN_LL4(a,b,c,d)      ll a,b,c,d;  is >> a >> b >> c >> d;
#define IN_STR(s)            string s;    is >> s;

//////////////////////////////////////////////////////////////////////////

istream& input(bool release_tie = false)
{
  ios_base::sync_with_stdio(false);
#ifdef INPUT_FROM_FILE
  static ifstream is("CodeForces/input.txt");
  return is;
#endif
  if (release_tie)
    cin.tie(NULL);
  return cin;
}

ostream& output(bool release_tie = false)
{
  cout << setprecision(15);
  if (release_tie)
    cout.tie(NULL);
  return cout;
}

template <typename T>
void init_v2(vector<vector<T>>& v, int lx, int ly, const T& val = T())
{
  v.resize(lx);
  FOR (i,0,lx)
    v[i].resize(ly, val);
};

//////////////////////////////////////////////////////////////////////////

////a
//void main()
//{
//  istream& is = input();
//  ostream& os = output();
//
//  IN_INT2(n,d);
//
//  vector<int> a(n);
//  FOR (i,0,n)
//    is >> a[i];
//  int res = 2;
//  FOR (i,0,n-1)
//  {
//    if (a[i+1]-a[i] >= 2*d)
//    {
//      if (a[i+1]-a[i] == 2*d)
//        ++res;
//      else
//        res+=2;
//    }
//  }
//
//  os << res;
//}

//////////////////////////////////////////////////////////////////////////
//c
void main()
{
  istream& is = input();
  ostream& os = output();

  IN_INT(n);

  vector<int> a(n);
  FOR (i,0,n)
    is >> a[i];

  ll res=0;
  vector<int> used(100000+1,0);
  map<int,int> exists;
  FOR (i,0,n-1)
    ++exists[a[i]];
  FOR_REV (i,1,n)
  {
    if (!used[a[i]])
    {
      used[a[i]] = 1;
      res+=exists.size();
    }
    if (--exists[a[i-1]])
      exists.erase(a[i-1]);
  }

  os << res;
}

//////////////////////////////////////////////////////////////////////////

//void main()
//{
//  istream& is = input();
//  ostream& os = output();
//
//  IN_INT(n);
//
//  //vector<int> a(n);
//  //FOR (i,0,n)
//  //  is >> a[i];
//
//  //os << res;
//}


#define _USE_MATH_DEFINES
#include <assert.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long     ll;
typedef unsigned int  UInt;
#define ALL(a)          (a).begin(), (a).end()
#define FOR(i,a,b)      for(int i = a;   i <  (int)(b); ++i)
#define FOR_REV(i,a,b)  for(int i = b-1; i >= (int)(a); --i)
#define FOR_EACH(it,a)  for(remove_reference<decltype(a)>::type::iterator it = (a).begin(); it != (a).end(); ++it)
#define FOR_EACH_REV(it,a) for(remove_reference<decltype(a)>::type::reverse_iterator it = (a).rbegin(); it != (a).rend(); ++it)
#define FOR_EACH_CONST(it,a) for(remove_reference<decltype(a)>::type::const_iterator it = (a).begin(); it != (a).end(); ++it)
#define FOR_EACH_CONST_REV(it,a) for(remove_reference<decltype(a)>::type::const_reverse_iterator it = (a).rbegin(); it != (a).rend(); ++it)
template<class T> inline T   sqr(T v)  { return v * v; }
template<class T> inline int sign(T v) { return v == 0 ? 0 : (v > 0 ? 1 : -1); }
template<class T> inline int get_bit(T v, int bit_index) { return (v >> bit_index) & 1; } //return {0,1}
template<class T> inline T   gcd(T a, T b) { while(b) { T t = b; b   = a % b; a   = t; } return a; }
#define IN_INT(a)            int a;       is >> a;
#define IN_INT2(a,b)         int a,b;     is >> a >> b;
#define IN_INT3(a,b,c)       int a,b,c;   is >> a >> b >> c;
#define IN_INT4(a,b,c,d)     int a,b,c,d; is >> a >> b >> c >> d;
#define IN_LL(a)             ll a;        is >> a;
#define IN_LL2(a,b)          ll a,b;      is >> a >> b;
#define IN_LL3(a,b,c)        ll a,b,c;    is >> a >> b >> c;
#define IN_LL4(a,b,c,d)      ll a,b,c,d;  is >> a >> b >> c >> d;
#define IN_STR(s)            string s;    is >> s;

//////////////////////////////////////////////////////////////////////////

istream& input(bool release_tie = false)
{
  ios_base::sync_with_stdio(false);
#ifdef INPUT_FROM_FILE
  static ifstream is("CodeForces/input.txt");
  return is;
#endif
  if (release_tie)
    cin.tie(NULL);
  return cin;
}

ostream& output(bool release_tie = false)
{
  cout << setprecision(15);
  if (release_tie)
    cout.tie(NULL);
  return cout;
}

template <typename T>
void init_v2(vector<vector<T>>& v, int lx, int ly, const T& val = T())
{
  v.resize(lx);
  FOR (i,0,lx)
    v[i].resize(ly, val);
};

//////////////////////////////////////////////////////////////////////////

////a
//void main()
//{
//  istream& is = input();
//  ostream& os = output();
//
//  IN_INT2(n,d);
//
//  vector<int> a(n);
//  FOR (i,0,n)
//    is >> a[i];
//  int res = 2;
//  FOR (i,0,n-1)
//  {
//    if (a[i+1]-a[i] >= 2*d)
//    {
//      if (a[i+1]-a[i] == 2*d)
//        ++res;
//      else
//        res+=2;
//    }
//  }
//
//  os << res;
//}

//////////////////////////////////////////////////////////////////////////
//c
void main()
{
  istream& is = input();
  ostream& os = output();

  IN_INT(n);

  vector<int> a(n);
  FOR (i,0,n)
    is >> a[i];

  ll res=0;
  vector<int> used(100000+1,0);
  map<int,int> exists;
  FOR (i,0,n-1)
    ++exists[a[i]];
  FOR_REV (i,1,n)
  {
    if (!used[a[i]])
    {
      used[a[i]] = 1;
      res+=exists.size();
    }
    if (!--exists[a[i-1]])
      exists.erase(a[i-1]);
  }

  os << res;
}

//////////////////////////////////////////////////////////////////////////
////b
//void main()
//{
//  istream& is = input();
//  ostream& os = output();
//  IN_INT(n);
//  FOR (i,0,n)
//    os << (i&1);
//}

//////////////////////////////////////////////////////////////////////////

//void main()
//{
//  istream& is = input();
//  ostream& os = output();
//
//  IN_INT(n);
//
//  //vector<int> a(n);
//  //FOR (i,0,n)
//  //  is >> a[i];
//
//  //os << res;
//}


#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	int n, i, m,j;
	long count = 0;
	int a[100003];
	int c[100003];
	int b[100002];
	memset(b, 0, sizeof(b));
	memset(c, 0, sizeof(c));
	cin >> n;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (i = n; i > 0; i--) {
		c[i] = c[i + 1];
		if (b[a[i] ]== 0) {//证明未重复
			c[i]++;
			b[a[i]] = 1;
		}
	}
	memset(b, 0, sizeof(b));
	for (i = 1; i < n; i++) {//不计算n
		if (b[a[i]] == 0) {
			count += c[i+1];
			b[a[i]] = 1;
		}
	}
	cout << count;
	return 0;
}


#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	int n, i, m,j;
	long long count = 0;
	int a[100003];
	int c[100003];
	int b[100002];
	memset(b, 0, sizeof(b));
	memset(c, 0, sizeof(c));
	cin >> n;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (i = n; i > 0; i--) {
		c[i] = c[i + 1];
		if (b[a[i] ]== 0) {//证明未重复
			c[i]++;
			b[a[i]] = 1;
		}
	}
	memset(b, 0, sizeof(b));
	for (i = 1; i < n; i++) {//不计算n
		if (b[a[i]] == 0) {
			count += c[i+1];
			b[a[i]] = 1;
		}
	}
	cout << count;
	return 0;
}


#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	int n, i, m,j,count=0;
	int a[100003];
	int c[100003];
	int b[100002];
	memset(b, 0, sizeof(b));
	memset(c, 0, sizeof(c));
	cin >> n;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (i = n; i > 0; i--) {
		c[i] = c[i + 1];
		if (b[a[i] ]== 0) {//证明未重复
			c[i]++;
			b[a[i]] = 1;
		}
	}
	memset(b, 0, sizeof(b));
	for (i = 1; i < n; i++) {//不计算n
		if (b[a[i]] == 0) {
			count += c[i+1];
			b[a[i]] = 1;
		}
	}
	cout << count;
	return 0;
}


#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	int n, i,j;
	long long count;
	count = 0;
	int a[100003] , b[10003] , c[10003];
	memset(b, 0, sizeof(b));
	memset(c, 0, sizeof(c));
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (i = 1; i < n; i++) {  //计算左边多少个重复
		for (j = 0; j <i; j++) {
			if (a[j] == a[i]) {
				b[i]++;
			}
		}
	}
	for (i = n-2; i>=0; i--) {  //计算右边多少个重复
		for (j = n-1; j >i; j--) {
			if (a[j] == a[i]) {
				c[i]++;
			}
		}
	}
	for (i = 0; i < n; i++) {
		for (j = n-1; j>i;j--) {
			if (b[i] == 0 && c[j] == 0) {
				count++;
			}
		}
	}
	cout << count;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

struct aa
{
	int p;  //位置
	int v;  //数字
}b[100005],c[100005];

bool cmp(aa x, aa y){
	return x.p<y.p;
}

bool cmp2(aa x, aa y){
	return x.p>y.p;
}

int w[100005];
bool f[100005];
int main(int argc, char const *argv[])
{
	int n,num=0;
	cin>>n;

	for (int i=0; i<n; i++) {
		cin>>w[i];
		if (!f[w[i]]) {
			b[num].p=i;
			b[num].v=w[i];
			num++;
			f[w[i]]=1;
		}
	}

	for (int i = n-1; i >= 0; i--)
	{
		f[w[i]]=0;
	}

	int num2=0;
	for (int i = n-1; i >= 0; i--)
	{
		if (!f[w[i]]) {
			c[num2].p=i;
			c[num2].v=w[i];
			num2++;
			f[w[i]]=1;
		}
	}

	sort(b, b+num, cmp);       //从左起的 顺着排
	sort(c, c+num2, cmp);      //从右起的 逆着排

	for (int i = 0; i < num; ++i)
	{
		// cout<<c[i].p<<' '<<c[i].v<<endl;
	}
// cout<<endl;

	int ans=0;

	for (int i = 0; i < num2; ++i)
	{
		w[i]=c[i].p; //cout<<w[i]<<' ';
	}
	// cout<<endl;

	for (int i = 0; i < num; i++)
	{
		// cout<<b[i].p<<' '<<b[i].v<<endl;
		// ans+=lower_bound(w, w+num2, b[i].p)-w;
		// cout<<b[i].p<<' ';

			ans+=num2-(upper_bound(w, w+num2, b[i].p)-w);
			// cout<<*upper_bound(w, w+num2, b[i].p)<<' '<<num2-(upper_bound(w, w+num2, b[i].p)-w)<<endl;

	}

	cout<<ans;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int w[100005],b[100005],c[100005];
bool f[100005];
int main()
{
	int n,num;
	cin>>n;

	for (int i=0; i<n; ++i) {
		cin>>w[i];
		f[w[i]]=0;
	}

	num=0;
	for (int i=0; i<n; ++i)
	{
		if (!f[w[i]]) {
			b[num]=i;           //记录下这个数第一次出现的位置（左起）
			num++;
			f[w[i]]=1;
		}
	}

	for (int i = n; i > 0; i--)
	{
		f[w[i]]=0;
	}

	int num2=0;
	for (int i = n; i > 0; i--)
	{
		if (!f[w[i]]) {
			c[num2]=i;             //记录下这个数第一次出现的位置（右起）
			num2++;
			f[w[i]]=1;
		}
	}

	sort(b, b+num);       //从左起的 第一个位置
	sort(c, c+num2);      //从右起的 第一个位置

	int ans=0;

	int l,r,mid;
	for (int i = 0; i < num; i++)
	{
		l=0; r=num2;
		for (int j=0; j<20; j++)
		{
			mid=(l+r)/2;
			if ( c[mid]<=b[i] ) l=mid+1;
			else r=mid;
		}
		ans+=(num2-l-1);
	}

	cout<<ans;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

struct aa
{
	int p;  //位置
	int v;  //数字
}b[100005],c[100005];

bool cmp(aa x, aa y){
	return x.p<y.p;
}

bool cmp2(aa x, aa y){
	return x.p>y.p;
}

int w[100005];
bool f[100005];
int main(int argc, char const *argv[])
{
	int n,num=0;
	cin>>n;

	for (int i=0; i<n; i++) {
		cin>>w[i];
		if (!f[w[i]]) {
			b[num].p=i;
			b[num].v=w[i];
			num++;
			f[w[i]]=1;
		}
	}

	for (int i = n-1; i >= 0; i--)
	{
		f[w[i]]=0;
	}

	int num2=0;
	for (int i = n-1; i >= 0; i--)
	{
		if (!f[w[i]]) {
			c[num2].p=i;
			c[num2].v=w[i];
			num2++;
			f[w[i]]=1;
		}
	}

	sort(b, b+num, cmp);       //从左起的 顺着排
	sort(c, c+num2, cmp);      //从右起的 逆着排

	for (int i = 0; i < num; ++i)
	{
		// cout<<c[i].p<<' '<<c[i].v<<endl;
	}
// cout<<endl;

	int ans=0;

	for (int i = 0; i < num2; ++i)
	{
		w[i]=c[i].p;
	}

	for (int i = 0; i < num; i++)
	{
		// cout<<b[i].p<<' '<<b[i].v<<endl;
		// ans+=lower_bound(w, w+num2, b[i].p)-w;
		if (upper_bound(w, w+num2, b[i].p)-w<num2) {
			ans+=num2-(upper_bound(w, w+num2, b[i].p)-w);
		}
	}

	cout<<ans;
	return 0;
}


#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int w[100015],b[100015],c[100015];
bool f[100015];
int main()
{
	int n,num;
	cin>>n;

	for (int i=1; i<=n; i++) cin>>w[i];

		memset(f,0,sizeof(f));

	num=0;
	for (int i=1; i<=n; i++)
	{
		if (!f[w[i]]) {
			b[num]=i;           //记录下这个数第一次出现的位置（左起）
			num++;
			f[w[i]]=1;
		}
	}

	memset(f,0,sizeof(f));

	int num2=0;
	for (int i = n; i >= 1; i--)
	{
		if (!f[w[i]]) {
			c[num2]=i;             //记录下这个数第一次出现的位置（右起）
			num2++;
			f[w[i]]=1;
		}
	}

	sort(b, b+num);       //从左起的 第一个位置
	sort(c, c+num2);      //从右起的 第一个位置

	long long ans=0;

	int l,r,mid;

	for (int i = 0; i < num; i++)
	{
		l=0; r=num2-1;
		for (int j=0; j<30; j++)
		{
			mid=(l+r)/2;
			if ( c[mid]<=b[i] ) l=mid;
			else r=mid;
		}
		if (c[l]>b[i]) ans+=(num2-l);
		else if (c[r]>b[i]) ans+=(num2-r);
	}

	cout<<ans;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int w[100005],b[100005],c[100005];
bool f[100005];
int main()
{
	int n,num;
	cin>>n;

	for (int i=0; i<n; ++i) {
		cin>>w[i];
		f[w[i]]=0;
	}

	num=0;
	for (int i=0; i<n; ++i)
	{
		if (!f[w[i]]) {
			b[num]=i;           //记录下这个数第一次出现的位置（左起）
			num++;
			f[w[i]]=1;
		}
	}

	for (int i = n; i > 0; i--)
	{
		f[w[i]]=0;
	}

	int num2=0;
	for (int i = n; i > 0; i--)
	{
		if (!f[w[i]]) {
			c[num2]=i;             //记录下这个数第一次出现的位置（右起）
			num2++;
			f[w[i]]=1;
		}
	}

	sort(b, b+num);       //从左起的 第一个位置
	sort(c, c+num2);      //从右起的 第一个位置

	int ans=0;

	int l,r,mid;
	for (int i = 0; i < num; i++)
	{
		l=0; r=num2-1;
		for (int j=0; j<20; j++)
		{
			mid=(l+r)/2;
			if ( c[mid]<=b[i] ) l=mid;
			else r=mid;
		}
		if (c[r]>b[i]) ans+=(num2-r-1);
	}

	cout<<ans;
	return 0;
}


#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int w[100015],b[100015],c[100015];
bool f[100015];
int main()
{
	int n,num;
	cin>>n;

	for (int i=1; i<=n; i++) cin>>w[i];

		memset(f,0,sizeof(f));

	num=0;
	for (int i=1; i<=n; i++)
	{
		if (!f[w[i]]) {
			b[num]=i;           //记录下这个数第一次出现的位置（左起）
			num++;
			f[w[i]]=1;
		}
	}

	memset(f,0,sizeof(f));

	int num2=0;
	for (int i = n; i >= 1; i--)
	{
		if (!f[w[i]]) {
			c[num2]=i;             //记录下这个数第一次出现的位置（右起）
			num2++;
			f[w[i]]=1;
		}
	}

	sort(b, b+num);       //从左起的 第一个位置
	sort(c, c+num2);      //从右起的 第一个位置

	int ans=0;

	int l,r,mid;

	for (int i = 0; i < num; i++)
	{
		l=0; r=num2-1;
		for (int j=0; j<30; j++)
		{
			mid=(l+r)/2;
			if ( c[mid]<=b[i] ) l=mid;
			else r=mid;
		}
		if (c[l]>b[i]) ans+=(num2-l);
		else if (c[r]>b[i]) ans+=(num2-r);
	}

	cout<<ans;
	return 0;
}


#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int w[100015],b[100015],c[100015];
bool f[100015];
int main()
{
	int n,num;
	cin>>n;

	for (int i=1; i<=n; i++) cin>>w[i];

		memset(f,0,sizeof(f));

	num=0;
	for (int i=1; i<=n; i++)
	{
		if (!f[w[i]]) {
			b[num]=i;           //记录下这个数第一次出现的位置（左起）
			num++;
			f[w[i]]=1;
		}
	}

	memset(f,0,sizeof(f));

	int num2=0;
	for (int i = n; i > 0; i--)
	{
		if (!f[w[i]]) {
			c[num2]=i;             //记录下这个数第一次出现的位置（右起）
			num2++;
			f[w[i]]=1;
		}
	}

	sort(b, b+num);       //从左起的 第一个位置
	sort(c, c+num2);      //从右起的 第一个位置

	int ans=0;

	int l,r,mid;

	for (int i = 0; i < num; i++)
	{
		l=0; r=num2-1;
		for (int j=0; j<30; j++)
		{
			mid=(l+r)/2;
			if ( c[mid]<=b[i] ) l=mid;
			else r=mid;
		}
		if (c[r]>b[i]) ans+=(num2-r);
	}

	cout<<ans;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int w[100005],b[100005],c[100005];
bool f[100005];
int main()
{
	int n,num;
	cin>>n;

	for (int i=0; i<n; ++i) {
		cin>>w[i];
		f[w[i]]=0;
	}

	num=0;
	for (int i=0; i<n; ++i)
	{
		if (!f[w[i]]) {
			b[num]=i;
			num++;
			f[w[i]]=1;
		}
	}

	for (int i = n; i > 0; i--)
	{
		f[w[i]]=0;
	}

	int num2=0;
	for (int i = n; i > 0; i--)
	{
		if (!f[w[i]]) {
			c[num2]=i;
			num2++;
			f[w[i]]=1;
		}
	}

	sort(b, b+num);       //从左起的 第一个位置
	sort(c, c+num2);      //从右起的 第一个位置

	int ans=0;

	for (int i = 0; i < num; i++)
	{
		ans+=num2-(upper_bound(c, c+num2, b[i])-c+1);
	}

	cout<<ans;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

struct aa
{
	int p;  //位置
	int v;  //数字
}b[100005],c[100005];

bool cmp(aa x, aa y){
	return x.p<y.p;
}

bool cmp2(aa x, aa y){
	return x.p>y.p;
}

int w[100005];
bool f[100005];
int main(int argc, char const *argv[])
{
	int n,num=0;
	cin>>n;

	for (int i=0; i<n; i++) {
		cin>>w[i];
		if (!f[w[i]]) {
			b[num].p=i;
			b[num].v=w[i];
			num++;
			f[w[i]]=1;
		}
	}

	for (int i = n-1; i >= 0; i--)
	{
		f[w[i]]=0;
	}

	int num2=0;
	for (int i = n-1; i >= 0; i--)
	{
		if (!f[w[i]]) {
			c[num2].p=i;
			c[num2].v=w[i];
			num2++;
			f[w[i]]=1;
		}
	}

	sort(b, b+num, cmp);       //从左起的 顺着排
	sort(c, c+num2, cmp);      //从右起的 逆着排

	for (int i = 0; i < num; ++i)
	{
		// cout<<c[i].p<<' '<<c[i].v<<endl;
	}
// cout<<endl;

	int ans=0;

	for (int i = 0; i < num2; ++i)
	{
		w[i]=c[i].p; //cout<<w[i]<<' ';
	}
	// cout<<endl;

	for (int i = 0; i < num; i++)
	{
		// cout<<b[i].p<<' '<<b[i].v<<endl;
		// ans+=lower_bound(w, w+num2, b[i].p)-w;
		// cout<<b[i].p<<' ';
		if (upper_bound(w, w+num2, b[i].p)-w<=num2) {
			ans+=num2-(upper_bound(w, w+num2, b[i].p)-w);
			// cout<<*upper_bound(w, w+num2, b[i].p)<<' '<<num2-(upper_bound(w, w+num2, b[i].p)-w)<<endl;
		}
	}

	cout<<ans;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int w[100015],b[100015],c[100015];
bool f[100015];
int main()
{
	int n,num;
	cin>>n;

	for (int i=0; i<n; ++i) {
		cin>>w[i];
		f[w[i]]=0;
	}

	num=0;
	for (int i=0; i<n; ++i)
	{
		if (!f[w[i]]) {
			b[num]=i;           //记录下这个数第一次出现的位置（左起）
			num++;
			f[w[i]]=1;
		}
	}

	for (int i = n; i > 0; i--)
	{
		f[w[i]]=0;
	}

	int num2=0;
	for (int i = n; i > 0; i--)
	{
		if (!f[w[i]]) {
			c[num2]=i;             //记录下这个数第一次出现的位置（右起）
			num2++;
			f[w[i]]=1;
		}
	}

	sort(b, b+num);       //从左起的 第一个位置
	sort(c, c+num2);      //从右起的 第一个位置

	int ans=0;

	int l,r,mid;
	for (int i = 0; i < num; i++)
	{
		l=0; r=num2+10;
		for (int j=0; j<25; j++)
		{
			mid=(l+r)/2;
			if ( c[mid]<=b[i] ) l=mid;
			else r=mid;
		}
		if (c[r]>b[i]) ans+=(num2-r-1);
	}

	cout<<ans;
	return 0;
}


#include <iostream>
#include <memory.h>
using namespace std;
const int nmax = 100 * 1000 + 5;
long long va[nmax];
bool ad_r[nmax];
bool su_r[nmax];
bool ar[nmax];
bool br[nmax];
long long dp[nmax];
long long v_br[nmax];
int main() {
	ios::sync_with_stdio(false);//加速cin
	memset(ad_r, false, sizeof(ad_r));
	memset(su_r, false, sizeof(su_r));
	memset(ar, false, sizeof(ar));
	memset(br, false, sizeof(br));
	memset(dp, 0, sizeof(dp));
	register int n, i,j;
	long long ans=0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> va[i];
	}
	for (i = 0; i < n; i++) {
		if (ad_r[va[i]]) {
			ar[i] = true;
		}
		ad_r[va[i]] = true;
	}
	v_br[n] = 0;
	for (i = n - 1; i >= 0; i--) {
		if (su_r[va[i]]) {
			br[i] = true;
			v_br[i] = v_br[i+1] ;
		}
		else {
			v_br[i] = v_br[i + 1]+1;
		}
		su_r[va[i]] = true;
		v_br[i - 1] = v_br[i] + 1;
	}
	i = n - 2;
	j = n - 1;
	if ((!ar[i]) && (!br[j])) {
		dp[n-2] = 1;
	}
	else {
		dp[n - 2] = 0;
	}
	for (i = n - 3; i >= 0; i--) {
		j = i + 1;
		if ((!ar[i])) {
				dp[i] = dp[i + 1] + v_br[i+1];
		}
		else {
			dp[i] = dp[i + 1];
		}
	}
	cout << dp[0] << endl;
	return 0;
}


#include <iostream>
#include <memory.h>
using namespace std;
const int nmax = 100 * 1000 + 5;
long long va[nmax];
bool ad_r[nmax];
bool su_r[nmax];
bool ar[nmax];
bool br[nmax];

int main() {
	ios::sync_with_stdio(false);//加速cin
	memset(ad_r, false, sizeof(ad_r));
	memset(su_r, false, sizeof(su_r));
	memset(ar, false, sizeof(ar));
	memset(br, false, sizeof(br));
	register int n, i,j;
	long long ans=0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> va[i];
	}
	for (i = 0; i < n; i++) {
		if (ad_r[va[i]]) {
			ar[i] = true;
		}
		ad_r[va[i]] = true;
	}
	for (i = n - 1; i >= 0; i--) {
		if (su_r[va[i]]) {
			br[i] = true;
		}
		su_r[va[i]] = true;
	}
	for (i = 0; i < n-1; i++) {
		for (j = i + 1; j < n; j++) {
			if ((!ar[i]) && (!br[j])) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


cnt = int(input())
data = [int(x) for x in input().split()]
#print(data)
totalSolutions = 0
s = set(data[:])
l = len(data)
dr = data[::-1]
for i in s:
    totalSolutions += len(set(data[data.index(i)+1:]))

print(totalSolutions)


cnt = int(input())
data = [int(x) for x in input().split()]
#print(data)
totalSolutions = 0
for i in set(data[:]):
    for j in set(data[:]):
        if data.index(i) < data.index(j):
            totalSolutions += 1
            #print(i,j)
print(totalSolutions)


cnt = int(input())
data = [int(x) for x in input().split()]
#print(data)
totalSolutions = 0
s = set(data[:])
l = len(data)
dr = data[::-1]
for i in s:
    for j in s:
        if data.index(i) < (l - dr.index(j) -1):
            totalSolutions += 1
            #print(i,j)

print(totalSolutions)


cnt = int(input())
data = [int(x) for x in input().split()]
#print(data)
totalSolutions = 0
for i in set(data[:]):
    for j in set(data[:]):
        if data.index(i) < (len(data) - data[::-1].index(j) -1):
            totalSolutions += 1
            #print(i,j)

print(totalSolutions)


cnt = int(input())
data = [int(x) for x in input().split()]
#print(data)
totalSolutions = 0
for i in set(data[:]):
    totalSolutions += len(set(data[data.index(i)+1:]))

print(totalSolutions)


n=int(input())
l=list(map(int,input().split()))
maxl=max(l)+1
dp=[]
for i in range(maxl):
    dp.append([-1,-1])
for i in range(n):
    dp[l[i]][1]=i
for i in range(n-1,-1,-1):
    dp[l[i]][0]=i
ll=[]
lr=[]
for i in range(n):
    ll.append(0)
    lr.append(0)
cnt = 0
for i in range(maxl):
    if(dp[i][0]!=-1):
        ll[dp[i][0]]=1
        lr[dp[i][1]]=1
        cnt+=1
ans = 0

for i in range(n):
    if(lr[i]==1):
        cnt-=1
    if(ll[i]==1):
        ans+=cnt
print(ans)


n=int(input())
a=[int(i)for i in input().split()]
total=0
b=set()
for i in range(n):
    if a[i]not in b:
        b.add(a[i])
        total+=len(set(a[i+1:]))
print(total)


n=int(input())
a=[int(i)for i in input().split()]
b=set()
for i in range(n-1):
    for k in range(i+1,n):
        b.add((a[i],a[k]))
print(len(b))


n=int(input())
a=[int(i)for i in input().split()]
c={}
for r in a:
    if r in c:
        c[r]+=1
    else:
        c[r]=1

total=0
b=set()
for i in range(n-1):
    c[a[i]]-=1
    if c[a[i]]==0:
            del c[a[i]]
    if a[i]not in b:
        b.add(a[i])

        total+=len(c)
print(total)


n = int(input())

a = [int(i) for i in input().split()]
from_r = [0] * n
st = set()

for i in range(n-1, -1, -1):
    st.add(a[i])
    from_r[i] = len(st)

if n == 1:
    exit(print(0))

st.clear()
ans = 0
for i in range(n-1):
    if a[i] in st:
        continue
    st.add(a[i])
    ans += from_r[i+1]

print(ans)


n = int(input())

a = [int(i) for i in input().split()]
from_l, from_r = [0] * n, [0] * n
st = set()

# for i, j in enumerate(a):
#     st.add(j)
#     from_l[i] = len(st)
#
# st.clear()

for i in range(n-1, -1, -1):
    st.add(a[i])
    from_r[i] = len(st)

if n == 1:
    exit(print(0))

# for i in from_r:
#     print(i, end=' ')

st.clear()
ans = 0
for i in range(n-1):
    if a[i] in st:
        continue
    st.add(i)
    ans += from_r[i+1]
    # print(ans)

print(ans)


n=int(input());
flag1=[0 for i in range(0,100006)];
cnt=[0 for i in range(0,100006)];
a=[int(y) for y in input().split()];
for i in range(0,n):
	if(flag1[a[i]]==0):
		flag1[a[i]]=1;
	else:
		cnt[i]=cnt[i-1]+1;
ans=0;
for i in range(n-1,-1,-1):
	ans+=i-cnt[i];
print(ans);


# import all important libraries and inbuilt functions
from __future__ import division, print_function
from fractions import Fraction
import numpy as np
import sys,bisect,copyreg,statistics,os,time,socket,socketserver
from math import *
from collections import Counter,defaultdict,deque,OrderedDict
from itertools import combinations,permutations,accumulate,groupby
from numpy.linalg import matrix_power as mp
from bisect import bisect_left,bisect_right,bisect,insort,insort_left,insort_right
from statistics import mode
from copy import copy
from functools import reduce,cmp_to_key
from io import BytesIO, IOBase
from scipy.spatial import ConvexHull
from heapq import *
from decimal import *
from queue import Queue,PriorityQueue
from re import sub,subn
from random import shuffle,randrange,randint,random

# end of library import

# map system version faults
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

# template of many functions used in competitive programming can add more later
# based on need we will use this commonly.

# bfs in a graph
def bfs(adj,v): # a schema of bfs
    visited=[False]*(v+1);q=deque()
    while q:pass

# definition of vertex of a graph
def graph(vertex): return [[] for i in range(vertex+1)]

def powermodulo(x, y, p) :
    res = 1;x = x % p
    if (x == 0) : return 0
    while (y > 0) :
        if ((y & 1) == 1) :   res = (res * x) % p
        y = y >> 1
        x = (x * x) % p
    return res

def lcm(a,b): return (a*b)//gcd(a,b)

# most common list in a array of lists
def most_frequent(List):return Counter(List).most_common(1)[0][0]

# element with highest frequency
def most_common(List):return(mode(List))

#In number theory, the Chinese remainder theorem states that
#if one knows the remainders of the Euclidean division of an integer n by
#several integers, then one can determine uniquely the remainder of the
#division of n by the product of these integers, under the condition
#that the divisors are pairwise coprime.
def chinese_remainder(a, p):
    prod = reduce(op.mul, p, 1);x = [prod // pi for pi in p]
    return sum(a[i] * powermodulo(x[i], p[i] - 2, p[i]) * x[i] for i in range(len(a))) % prod

# make a matrix
def createMatrix(rowCount, colCount, dataList):
    mat = []
    for i in range (rowCount):
        rowList = []
        for j in range (colCount):
            if dataList[j] not in mat:rowList.append(dataList[j])
        mat.append(rowList)
    return mat

# input for a binary tree
def readTree():
    v=int(inp());adj=[set() for i in range(v+1)]
    for i in range(v-1):u1,u2=In(); adj[u1].add(u2);adj[u2].add(u1)
    return adj,v

# sieve of prime numbers
def sieve():
    li=[True]*1000001;li[0],li[1]=False,False;prime=[]
    for i in range(2,len(li),1):
        if li[i]==True:
            for j in range(i*i,len(li),i):li[j]=False
    for i in range(1000001):
        if li[i]==True:prime.append(i)
    return prime

#count setbits of a number.
def setBit(n):
    count=0
    while n!=0:n=n&(n-1);count+=1
    return count

# sum of digits of a number
def digitsSum(n):
    if n == 0:return 0
    r = 0
    while n > 0:r += n % 10;n //= 10
    return r

# ncr efficiently
def ncr(n, r):
    r = min(r, n - r);numer = reduce(op.mul, range(n, n - r, -1), 1);denom = reduce(op.mul, range(1, r + 1), 1)
    return numer // denom  # or / in Python 2

#factors of a number
def factors(n):return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))

#prime fators of a number
def prime_factors(n):
    i = 2;factors = []
    while i * i <= n:
        if n % i:i += 1
        else:n //= i;factors.append(i)
    if n > 1:factors.append(n)
    return set(factors)

def prefixSum(arr):
    for i in range(1, len(arr)):arr[i] = arr[i] + arr[i-1]
    return arr

def binomial_coefficient(n, k):
    if 0 <= k <= n:
        ntok = 1;ktok = 1
        for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1
        return ntok // ktok
    else:return 0

def powerOfK(k, max):
    if k == 1:return [1]
    if k == -1:return [-1, 1]
    result = [];n = 1
    while n <= max:result.append(n);n *= k
    return result

# maximum subarray sum use kadane's algorithm
def kadane(a,size):
    max_so_far = 0;max_ending_here = 0
    for i in range(0, size):
        max_ending_here = max_ending_here + a[i]
        if (max_so_far < max_ending_here):max_so_far = max_ending_here
        if max_ending_here < 0:max_ending_here = 0
    return max_so_far

def divisors(n):
    result = []
    for i in range(1,ceil(sqrt(n))+1):
        if n%i == 0:
            if n/i == i:result.append(i)
            else:result.append(i);result.append(n/i)
    return result

def sumtilln(n): return ((n*(n+1))//2)

def isPrime(n) :
	if (n <= 1) :return False
	if (n <= 3) :return True
	if (n % 2 == 0 or n % 3 == 0) :return False
	for i in range(5,ceil(sqrt(n))+1,6):
		if (n % i == 0 or n % (i + 2) == 0) :return False
	return True

def isPowerOf2(n):
    while n % 2 == 0:n //= 2
    return (True if n == 1 else False)

def power2(n):
    k = 0
    while n % 2 == 0:k += 1;n //= 2
    return k

def sqsum(n):return ((n*(n+1))*(2*n+1)//6)

def cusum(n):return ((sumn(n))**2)

def pa(a):
    for i in range(len(a)):print(a[i], end = " ")
    print()

def pm(a,rown,coln):
    for i in range(rown):
        for j in range(coln):print(a[i][j],end = " ")
        print()

def pmasstring(a,rown,coln):
    for i in range(rown):
        for j in range(coln):print(a[i][j],end = "")
        print()

def isPerfectSquare(n):return pow(floor(sqrt(n)),2) == n

def nC2(n,m):return (((n*(n-1))//2) % m)

def modInverse(n,p):return powermodulo(n,p-2,p)

def ncrmodp(n, r, p):
	num = den = 1
	for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p
	return (num * powermodulo(den,p - 2, p)) % p

def reverse(string):return "".join(reversed(string))

def listtostr(s):return ' '.join([str(elem) for elem in s])

def binarySearch(arr, l, r, x):
	while l <= r:
		mid = l + (r - l) // 2;
		if arr[mid] == x:return mid
		elif arr[mid] < x:l = mid + 1
		else:r = mid - 1
	return -1

def isarrayodd(a):
    r = True
    for i in range(len(a)):
        if a[i] % 2 == 0:
            r = False
            break
    return r

def isPalindrome(s):return s == s[::-1]

def gt(x,h,c,t):return ((x*h+(x-1)*c)/(2*x-1))

def CountFrequency(my_list):
    freq = {}
    for item in my_list:freq[item] = (freq[item] + 1 if (item in freq) else 1)
    return freq

def CountFrequencyasPair(my_list1,my_list2,freq):
    for item in my_list1:freq[item][0] = (freq[item][0] + 1 if (item in freq) else 1)
    for item in my_list2:freq[item][1] = (freq[item][1] + 1 if (item in freq) else 1)
    return freq

def binarySearchCount(arr, n, key):
    left = 0;right = n - 1;count = 0
    while (left <= right):
        mid = int((right + left) / 2)
        if (arr[mid] <= key):count,left = mid + 1,mid + 1
        else:right = mid - 1
    return count

def primes(n):
  sieve,l = [True] * (n+1),[]
  for p in range(2, n+1):
    if (sieve[p]):
      l.append(p)
      for i in range(p, n+1, p):sieve[i] = False
  return l

def Next_Greater_Element_for_all_in_array(arr):
	s,n,reta,retb = list(),len(arr),[],[];arr1 = [list([0,i]) for i in range(n)]
	for i in range(n - 1, -1, -1):
		while (len(s) > 0 and s[-1][0] <= arr[i]):s.pop()
		if (len(s) == 0):arr1[i][0] = -1
		else:arr1[i][0] = s[-1]
		s.append(list([arr[i],i]))
	for i in range(n):reta.append(list([arr[i],i]));retb.append(arr1[i][0])
	return reta,retb

def polygonArea(X,Y,n):
    area = 0.0;j = n - 1
    for i in range(n):area += (X[j] + X[i]) * (Y[j] - Y[i]);j = i
    return abs(area / 2.0)

def merge(a, b):
	ans = defaultdict(int)
	for i in a:ans[i] += a[i]
	for i in b:ans[i] += b[i]
	return ans

# Print the all possible subset sums that lie in a particular interval of l <= sum <= target
def subset_sum(numbers,l,target, partial=[]):
    s = sum(partial)
    if l <= s <= target:print ("sum(%s)=%s" % (partial, s))
    if s >= target:return
    for i in range(len(numbers)):subset_sum(numbers[i+1:], l,target, partial + [numbers[i]])

#defining a LRU Cache
# where we can set values and get values based on our requirement
class LRUCache:
	# initialising capacity
	def __init__(self, capacity: int):
		self.cache = OrderedDict()
		self.capacity = capacity

	# we return the value of the key
	# that is queried in O(1) and return -1 if we
	# don't find the key in out dict / cache.
	# And also move the key to the end
	# to show that it was recently used.
	def get(self, key: int) -> int:
		if key not in self.cache:return -1
		else:self.cache.move_to_end(key);return self.cache[key]

	# first, we add / update the key by conventional methods.
	# And also move the key to the end to show that it was recently used.
	# But here we will also check whether the length of our
	# ordered dictionary has exceeded our capacity,
	# If so we remove the first key (least recently used)
	def put(self, key: int, value: int) -> None:
		self.cache[key] = value;self.cache.move_to_end(key)
		if len(self.cache) > self.capacity:self.cache.popitem(last = False)

class segtree:
    def __init__(self,n):
        self.m = 1
        while self.m < n:self.m *= 2
        self.data = [0] * (2 * self.m)
    def __setitem__(self,i,x):
        x = +(x != 1);i += self.m;self.data[i] = x;i >>= 1
        while i:self.data[i] = self.data[2 * i] + self.data[2 * i + 1];i >>= 1
    def __call__(self,l,r):
        l += self.m;r += self.m;s = 0
        while l < r:
            if l & 1:s += self.data[l];l += 1
            if r & 1:r -= 1;s += self.data[r]
            l >>= 1;r >>= 1
        return s

class FenwickTree:
  def __init__(self, n):self.n = n;self.bit = [0]*(n+1)
  def update(self, x, d):
    while x <= self.n:self.bit[x] += d;x += (x & (-x))
  def query(self, x):
    res = 0
    while x > 0:res += self.bit[x];x -= (x & (-x))
    return res
  def range_query(self, l, r):return self.query(r) - self.query(l-1)
# can add more template functions here

# end of template functions

# To enable the file I/O i the below 2 lines are uncommented.
# read from in.txt if uncommented
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
# will print on Console if file I/O is not activated
#if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')

# inputs template
#for fast input we areusing sys.stdin
def inp(): return sys.stdin.readline().strip()

#for fast output, always take string
def out(var): sys.stdout.write(str(var))

# custom base input needed for the program
def I():return (inp())
def II():return (int(inp()))
def FI():return (float(inp()))
def SI():return (list(str(inp())))
def MI():return (map(int,inp().split()))
def LI():return (list(MI()))
def SLI():return (sorted(LI()))
def MF():return (map(float,inp().split()))
def LF():return (list(MF()))
def SLF():return (sorted(LF()))

# end of inputs template

# common modulo values used in competitive programming
MOD = 998244353
mod = 10**9+7

# any particular user-defined functions for the code.
# can be written here.

# end of any user-defined functions

# main functions for execution of the program.
if __name__ == '__main__':
    # execute your program from here.
    # start your main code from here

    # Write your code here
    for _ in range(II()):pa([1]*(II()))

    # end of main code
    # end of program

# This program is written by :
#   Shubham Gupta
#   B.Tech (2019-2023)
#   Computer Science and Engineering,
#   Department of EECS
#   Contact No:8431624358
#   Indian Institute of Technology(IIT),Bhilai
#   Sejbahar,
#   Datrenga,
#   Raipur,
#   Chhattisgarh
#   492015

#   THANK YOU FOR
#YOUR KIND PATIENCE FOR READING THE PROGRAM.


# import all important libraries and inbuilt functions
from __future__ import division, print_function
from fractions import Fraction
import numpy as np
import sys,bisect,copyreg,statistics,os,time,socket,socketserver
from math import *
from collections import Counter,defaultdict,deque,OrderedDict
from itertools import combinations,permutations,accumulate,groupby
from numpy.linalg import matrix_power as mp
from bisect import bisect_left,bisect_right,bisect,insort,insort_left,insort_right
from statistics import mode
from copy import copy
from functools import reduce,cmp_to_key
from io import BytesIO, IOBase
from scipy.spatial import ConvexHull
from heapq import *
from decimal import *
from queue import Queue,PriorityQueue
from re import sub,subn
from random import shuffle,randrange,randint,random

# end of library import

# map system version faults
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

# template of many functions used in competitive programming can add more later
# based on need we will use this commonly.

# bfs in a graph
def bfs(adj,v): # a schema of bfs
    visited=[False]*(v+1);q=deque()
    while q:pass

# definition of vertex of a graph
def graph(vertex): return [[] for i in range(vertex+1)]

def powermodulo(x, y, p) :
    res = 1;x = x % p
    if (x == 0) : return 0
    while (y > 0) :
        if ((y & 1) == 1) :   res = (res * x) % p
        y = y >> 1
        x = (x * x) % p
    return res

def lcm(a,b): return (a*b)//gcd(a,b)

# most common list in a array of lists
def most_frequent(List):return Counter(List).most_common(1)[0][0]

# element with highest frequency
def most_common(List):return(mode(List))

#In number theory, the Chinese remainder theorem states that
#if one knows the remainders of the Euclidean division of an integer n by
#several integers, then one can determine uniquely the remainder of the
#division of n by the product of these integers, under the condition
#that the divisors are pairwise coprime.
def chinese_remainder(a, p):
    prod = reduce(op.mul, p, 1);x = [prod // pi for pi in p]
    return sum(a[i] * powermodulo(x[i], p[i] - 2, p[i]) * x[i] for i in range(len(a))) % prod

# make a matrix
def createMatrix(rowCount, colCount, dataList):
    mat = []
    for i in range (rowCount):
        rowList = []
        for j in range (colCount):
            if dataList[j] not in mat:rowList.append(dataList[j])
        mat.append(rowList)
    return mat

# input for a binary tree
def readTree():
    v=int(inp());adj=[set() for i in range(v+1)]
    for i in range(v-1):u1,u2=In(); adj[u1].add(u2);adj[u2].add(u1)
    return adj,v

# sieve of prime numbers
def sieve():
    li=[True]*1000001;li[0],li[1]=False,False;prime=[]
    for i in range(2,len(li),1):
        if li[i]==True:
            for j in range(i*i,len(li),i):li[j]=False
    for i in range(1000001):
        if li[i]==True:prime.append(i)
    return prime

#count setbits of a number.
def setBit(n):
    count=0
    while n!=0:n=n&(n-1);count+=1
    return count

# sum of digits of a number
def digitsSum(n):
    if n == 0:return 0
    r = 0
    while n > 0:r += n % 10;n //= 10
    return r

# ncr efficiently
def ncr(n, r):
    r = min(r, n - r);numer = reduce(op.mul, range(n, n - r, -1), 1);denom = reduce(op.mul, range(1, r + 1), 1)
    return numer // denom  # or / in Python 2

#factors of a number
def factors(n):return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))

#prime fators of a number
def prime_factors(n):
    i = 2;factors = []
    while i * i <= n:
        if n % i:i += 1
        else:n //= i;factors.append(i)
    if n > 1:factors.append(n)
    return set(factors)

def prefixSum(arr):
    for i in range(1, len(arr)):arr[i] = arr[i] + arr[i-1]
    return arr

def binomial_coefficient(n, k):
    if 0 <= k <= n:
        ntok = 1;ktok = 1
        for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1
        return ntok // ktok
    else:return 0

def powerOfK(k, max):
    if k == 1:return [1]
    if k == -1:return [-1, 1]
    result = [];n = 1
    while n <= max:result.append(n);n *= k
    return result

# maximum subarray sum use kadane's algorithm
def kadane(a,size):
    max_so_far = 0;max_ending_here = 0
    for i in range(0, size):
        max_ending_here = max_ending_here + a[i]
        if (max_so_far < max_ending_here):max_so_far = max_ending_here
        if max_ending_here < 0:max_ending_here = 0
    return max_so_far

def divisors(n):
    result = []
    for i in range(1,ceil(sqrt(n))+1):
        if n%i == 0:
            if n/i == i:result.append(i)
            else:result.append(i);result.append(n/i)
    return result

def sumtilln(n): return ((n*(n+1))//2)

def isPrime(n) :
	if (n <= 1) :return False
	if (n <= 3) :return True
	if (n % 2 == 0 or n % 3 == 0) :return False
	for i in range(5,ceil(sqrt(n))+1,6):
		if (n % i == 0 or n % (i + 2) == 0) :return False
	return True

def isPowerOf2(n):
    while n % 2 == 0:n //= 2
    return (True if n == 1 else False)

def power2(n):
    k = 0
    while n % 2 == 0:k += 1;n //= 2
    return k

def sqsum(n):return ((n*(n+1))*(2*n+1)//6)

def cusum(n):return ((sumn(n))**2)

def pa(a):
    for i in range(len(a)):print(a[i], end = " ")
    print()

def pm(a,rown,coln):
    for i in range(rown):
        for j in range(coln):print(a[i][j],end = " ")
        print()

def pmasstring(a,rown,coln):
    for i in range(rown):
        for j in range(coln):print(a[i][j],end = "")
        print()

def isPerfectSquare(n):return pow(floor(sqrt(n)),2) == n

def nC2(n,m):return (((n*(n-1))//2) % m)

def modInverse(n,p):return powermodulo(n,p-2,p)

def ncrmodp(n, r, p):
	num = den = 1
	for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p
	return (num * powermodulo(den,p - 2, p)) % p

def reverse(string):return "".join(reversed(string))

def listtostr(s):return ' '.join([str(elem) for elem in s])

def binarySearch(arr, l, r, x):
	while l <= r:
		mid = l + (r - l) // 2;
		if arr[mid] == x:return mid
		elif arr[mid] < x:l = mid + 1
		else:r = mid - 1
	return -1

def isarrayodd(a):
    r = True
    for i in range(len(a)):
        if a[i] % 2 == 0:
            r = False
            break
    return r

def isPalindrome(s):return s == s[::-1]

def gt(x,h,c,t):return ((x*h+(x-1)*c)/(2*x-1))

def CountFrequency(my_list):
    freq = {}
    for item in my_list:freq[item] = (freq[item] + 1 if (item in freq) else 1)
    return freq

def CountFrequencyasPair(my_list1,my_list2,freq):
    for item in my_list1:freq[item][0] = (freq[item][0] + 1 if (item in freq) else 1)
    for item in my_list2:freq[item][1] = (freq[item][1] + 1 if (item in freq) else 1)
    return freq

def binarySearchCount(arr, n, key):
    left = 0;right = n - 1;count = 0
    while (left <= right):
        mid = int((right + left) / 2)
        if (arr[mid] <= key):count,left = mid + 1,mid + 1
        else:right = mid - 1
    return count

def primes(n):
  sieve,l = [True] * (n+1),[]
  for p in range(2, n+1):
    if (sieve[p]):
      l.append(p)
      for i in range(p, n+1, p):sieve[i] = False
  return l

def Next_Greater_Element_for_all_in_array(arr):
	s,n,reta,retb = list(),len(arr),[],[];arr1 = [list([0,i]) for i in range(n)]
	for i in range(n - 1, -1, -1):
		while (len(s) > 0 and s[-1][0] <= arr[i]):s.pop()
		if (len(s) == 0):arr1[i][0] = -1
		else:arr1[i][0] = s[-1]
		s.append(list([arr[i],i]))
	for i in range(n):reta.append(list([arr[i],i]));retb.append(arr1[i][0])
	return reta,retb

def polygonArea(X,Y,n):
    area = 0.0;j = n - 1
    for i in range(n):area += (X[j] + X[i]) * (Y[j] - Y[i]);j = i
    return abs(area / 2.0)

def merge(a, b):
	ans = defaultdict(int)
	for i in a:ans[i] += a[i]
	for i in b:ans[i] += b[i]
	return ans

# Print the all possible subset sums that lie in a particular interval of l <= sum <= target
def subset_sum(numbers,l,target, partial=[]):
    s = sum(partial)
    if l <= s <= target:print ("sum(%s)=%s" % (partial, s))
    if s >= target:return
    for i in range(len(numbers)):subset_sum(numbers[i+1:], l,target, partial + [numbers[i]])

#defining a LRU Cache
# where we can set values and get values based on our requirement
class LRUCache:
	# initialising capacity
	def __init__(self, capacity: int):
		self.cache = OrderedDict()
		self.capacity = capacity

	# we return the value of the key
	# that is queried in O(1) and return -1 if we
	# don't find the key in out dict / cache.
	# And also move the key to the end
	# to show that it was recently used.
	def get(self, key: int) -> int:
		if key not in self.cache:return -1
		else:self.cache.move_to_end(key);return self.cache[key]

	# first, we add / update the key by conventional methods.
	# And also move the key to the end to show that it was recently used.
	# But here we will also check whether the length of our
	# ordered dictionary has exceeded our capacity,
	# If so we remove the first key (least recently used)
	def put(self, key: int, value: int) -> None:
		self.cache[key] = value;self.cache.move_to_end(key)
		if len(self.cache) > self.capacity:self.cache.popitem(last = False)

class segtree:
    def __init__(self,n):
        self.m = 1
        while self.m < n:self.m *= 2
        self.data = [0] * (2 * self.m)
    def __setitem__(self,i,x):
        x = +(x != 1);i += self.m;self.data[i] = x;i >>= 1
        while i:self.data[i] = self.data[2 * i] + self.data[2 * i + 1];i >>= 1
    def __call__(self,l,r):
        l += self.m;r += self.m;s = 0
        while l < r:
            if l & 1:s += self.data[l];l += 1
            if r & 1:r -= 1;s += self.data[r]
            l >>= 1;r >>= 1
        return s

class FenwickTree:
  def __init__(self, n):self.n = n;self.bit = [0]*(n+1)
  def update(self, x, d):
    while x <= self.n:self.bit[x] += d;x += (x & (-x))
  def query(self, x):
    res = 0
    while x > 0:res += self.bit[x];x -= (x & (-x))
    return res
  def range_query(self, l, r):return self.query(r) - self.query(l-1)
# can add more template functions here

# end of template functions

# To enable the file I/O i the below 2 lines are uncommented.
# read from in.txt if uncommented
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
# will print on Console if file I/O is not activated
#if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')

# inputs template
#for fast input we areusing sys.stdin
def inp(): return sys.stdin.readline().strip()

#for fast output, always take string
def out(var): sys.stdout.write(str(var))

# custom base input needed for the program
def I():return (inp())
def II():return (int(inp()))
def FI():return (float(inp()))
def SI():return (list(str(inp())))
def MI():return (map(int,inp().split()))
def LI():return (list(MI()))
def SLI():return (sorted(LI()))
def MF():return (map(float,inp().split()))
def LF():return (list(MF()))
def SLF():return (sorted(LF()))

# end of inputs template

# common modulo values used in competitive programming
MOD = 998244353
mod = 10**9+7

# any particular user-defined functions for the code.
# can be written here.
for _ in range(II()):pa([1]*(II()))
# end of any user-defined functions

# main functions for execution of the program.
#if __name__ == '__main__':
    # execute your program from here.
    # start your main code from here

    # Write your code here
    #for _ in range(II()):pa([1]*(II()))

    # end of main code
    # end of program

# This program is written by :
#   Shubham Gupta
#   B.Tech (2019-2023)
#   Computer Science and Engineering,
#   Department of EECS
#   Contact No:8431624358
#   Indian Institute of Technology(IIT),Bhilai
#   Sejbahar,
#   Datrenga,
#   Raipur,
#   Chhattisgarh
#   492015

#   THANK YOU FOR
#YOUR KIND PATIENCE FOR READING THE PROGRAM.


# import all important libraries and inbuilt functions
from __future__ import division, print_function
from fractions import Fraction
import sys,bisect,heapq,copyreg,copy,statistics,os
from math import *
from collections import Counter,defaultdict,deque,OrderedDict
from itertools import combinations,permutations,accumulate
from bisect import bisect_left,bisect_right,bisect
from statistics import mode
from functools import reduce
from io import BytesIO, IOBase
from decimal import *

# end of library import

# map system version faults
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

# template of many functions used in competitive programming can add more later
# based on need we will use this commonly.

# bfs in a graph
def bfs(adj,v): # a schema of bfs
    visited=[False]*(v+1);q=deque()
    while q:pass

# definition of vertex of a graph
def graph(vertex): return [[] for i in range(vertex+1)]

def lcm(a,b): return (a*b)//gcd(a,b)

# most common list in a array of lists
def most_frequent(List):return Counter(List).most_common(1)[0][0]

# element with highest frequency
def most_common(List):return(mode(List))

#In number theory, the Chinese remainder theorem states that
#if one knows the remainders of the Euclidean division of an integer n by
#several integers, then one can determine uniquely the remainder of the
#division of n by the product of these integers, under the condition
#that the divisors are pairwise coprime.
def chinese_remainder(a, p):
    prod = reduce(op.mul, p, 1);x = [prod // pi for pi in p]
    return sum(a[i] * pow(x[i], p[i] - 2, p[i]) * x[i] for i in range(len(a))) % prod

# make a matrix
def createMatrix(rowCount, colCount, dataList):
    mat = []
    for i in range (rowCount):
        rowList = []
        for j in range (colCount):
            if dataList[j] not in mat:rowList.append(dataList[j])
        mat.append(rowList)
    return mat

# input for a binary tree
def readTree():
    v=int(inp());adj=[set() for i in range(v+1)]
    for i in range(v-1):u1,u2=In(); adj[u1].add(u2);adj[u2].add(u1)
    return adj,v

# sieve of prime numbers
def sieve():
    li=[True]*1000001;li[0],li[1]=False,False;prime=[]
    for i in range(2,len(li),1):
        if li[i]==True:
            for j in range(i*i,len(li),i):li[j]=False
    for i in range(1000001):
        if li[i]==True:prime.append(i)
    return prime

#count setbits of a number.
def setBit(n):
    count=0
    while n!=0:n=n&(n-1);count+=1
    return count

# sum of digits of a number
def digitsSum(n):
    if n == 0:return 0
    r = 0
    while n > 0:r += n % 10;n //= 10
    return r

# ncr efficiently
def ncr(n, r):
    r = min(r, n - r);numer = reduce(op.mul, range(n, n - r, -1), 1);denom = reduce(op.mul, range(1, r + 1), 1)
    return numer // denom  # or / in Python 2

#factors of a number
def factors(n):return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))

#prime fators of a number
def prime_factors(n):
    i = 2;factors = []
    while i * i <= n:
        if n % i:i += 1
        else:n //= i;factors.append(i)
    if n > 1:factors.append(n)
    return len(set(factors))

def prefixSum(arr):
    for i in range(1, len(arr)):arr[i] = arr[i] + arr[i-1]
    return arr

def binomial_coefficient(n, k):
    if 0 <= k <= n:
        ntok = 1;ktok = 1
        for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1
        return ntok // ktok
    else:return 0

def powerOfK(k, max):
    if k == 1:return [1]
    if k == -1:return [-1, 1]
    result = [];n = 1
    while n <= max:result.append(n);n *= k
    return result

# maximum subarray sum use kadane's algorithm
def kadane(a,size):
    max_so_far = 0;max_ending_here = 0
    for i in range(0, size):
        max_ending_here = max_ending_here + a[i]
        if (max_so_far < max_ending_here):max_so_far = max_ending_here
        if max_ending_here < 0:max_ending_here = 0
    return max_so_far

def divisors(n):
    result = []
    for i in range(1,ceil(sqrt(n))+1):
        if n%i == 0:
            if n/i == i:result.append(i)
            else:result.append(i);result.append(n/i)
    return result

def sumyilln(n): return ((n*(n+1))//2)

def isPrime(n) :
	if (n <= 1) :return False
	if (n <= 3) :return True
	if (n % 2 == 0 or n % 3 == 0) :return False
	for i in range(5,ceil(sqrt(n))+1,6):
		if (n % i == 0 or n % (i + 2) == 0) :return False
	return True

def isPowerOf2(n):
    while n % 2 == 0:n //= 2
    return (True if n == 1 else False)

def power2(n):
    k = 0
    while n % 2 == 0:k += 1;n //= 2
    return k

def sqsum(n):return ((n*(n+1))*(2*n+1)//6)

def cusum(n):return ((sumn(n))**2)

def pa(a):
    for i in range(len(a)):print(a[i], end = " ")
    print()

def pm(a,rown,coln):
    for i in range(rown):
        for j in range(coln):print(a[i][j],end = " ")
        print()

def pmasstring(a,rown,coln):
    for i in range(rown):
        for j in range(coln):print(a[i][j],end = "")
        print()
def isPerfectSquare(n):return pow(floor(sqrt(n)),2) == n

def nC2(n,m):return (((n*(n-1))//2) % m)

def modInverse(n,p):return pow(n,p-2,p)

def ncrmodp(n, r, p):
	num = den = 1
	for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p
	return (num * pow(den,p - 2, p)) % p

def reverse(string):return "".join(reversed(string))

def listtostr(s):return ' '.join([str(elem) for elem in s])

def binarySearch(arr, l, r, x):
	while l <= r:
		mid = l + (r - l) // 2;
		if arr[mid] == x:return mid
		elif arr[mid] < x:l = mid + 1
		else:r = mid - 1
	return -1

def isPalindrome(s):return s == s[::-1]

def gt(x,h,c,t):return ((x*h+(x-1)*c)/(2*x-1))

def CountFrequency(my_list):
    freq = {}
    for item in my_list:freq[item] = (freq[item] + 1 if (item in freq) else 1)
    return freq

def CountFrequencyasPair(my_list1,my_list2,freq):
    for item in my_list1:freq[item][0] = (freq[item][0] + 1 if (item in freq) else 1)
    for item in my_list2:freq[item][1] = (freq[item][1] + 1 if (item in freq) else 1)
    return freq

def binarySearchCount(arr, n, key):
	left = 0;right = n ;mid = 0
	while (left < right):
		mid = (right + left)//2
		if (arr[mid] == key):
			while (mid + 1<n and arr[mid + 1] == key): 	mid+= 1
			break
		elif (arr[mid] > key): 	right = mid
		else: 	left = mid + 1
	while (mid > -1 and arr[mid] > key):		mid-= 1
	return mid

def primes(n):
  sieve,l = [True] * (n+1),[]
  for p in range(2, n+1):
    if (sieve[p]):
      l.append(p)
      for i in range(p, n+1, p):sieve[i] = False
  return l

def Next_Greater_Element_for_all_in_array(arr):
	s,n,reta,retb = list(),len(arr),[],[];arr1 = [list([0,i]) for i in range(n)]
	for i in range(n - 1, -1, -1):
		while (len(s) > 0 and s[-1][0] <= arr[i]):s.pop()
		if (len(s) == 0):arr1[i][0] = -1
		else:arr1[i][0] = s[-1]
		s.append(list([arr[i],i]))
	for i in range(n):reta.append(list([arr[i],i]));retb.append(arr1[i][0])
	return reta,retb

#defining a LRU Cache
# where we can set values and get values based on our requirement
class LRUCache:

	# initialising capacity
	def __init__(self, capacity: int):
		self.cache = OrderedDict()
		self.capacity = capacity

	# we return the value of the key
	# that is queried in O(1) and return -1 if we
	# don't find the key in out dict / cache.
	# And also move the key to the end
	# to show that it was recently used.
	def get(self, key: int) -> int:
		if key not in self.cache:return -1
		else:self.cache.move_to_end(key);return self.cache[key]

	# first, we add / update the key by conventional methods.
	# And also move the key to the end to show that it was recently used.
	# But here we will also check whether the length of our
	# ordered dictionary has exceeded our capacity,
	# If so we remove the first key (least recently used)
	def put(self, key: int, value: int) -> None:
		self.cache[key] = value;self.cache.move_to_end(key)
		if len(self.cache) > self.capacity:self.cache.popitem(last = False)

# can add more template functions here

# end of template functions

# To enable the file I/O i the below 2 lines are uncommented.
# read from in.txt if uncommented
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
# will print on Console if file I/O is not activated
#if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')

# inputs template
#for fast input we areusing sys.stdin
def inp(): return sys.stdin.readline().strip()

#for fast output, always take string
def out(var): sys.stdout.write(str(var))

# cusom base input needed for the program
def I():return (inp())
def II():return (int(inp()))
def FI():return (float(inp()))
def SI():return (list(str(inp())))
def MI():return (map(int,inp().split()))
def LI():return (list(MI()))
def MF():return (map(float,inp().split()))
def LF():return (list(MF()))

# end of inputs template

# common modulo values used in competitive programming
MOD = 10**9+7
mod = 998244353

# any particular user-defined functions for the code.
# can be written here.

# end of any user-defined functions

# main functions for execution of the program.
if __name__ == '__main__':
    # execute your program from here.
    # start your main code from here

    # Write your code here.
    for _ in range(II()):pa([1]*(II()))

    # end of main code
    # end of program

# This program is written by :
#   Shubham Gupta
#   B.Tech (2019-2023)
#   Computer Science and Engineering,
#   Department of EECS
#   Contact No:8431624358
#   Indian Institute of Technology(IIT),Bhilai
#   Sejbahar,
#   Datrenga,
#   Raipur,
#   Chhattisgarh
#   492015

#   THANK YOU FOR
#YOUR KIND PATIENCE FOR READING THE PROGRAM.


t = int(input())
while t:
    l = []
    n = int(input())
    b = n % 2
    n = n // 2
    a = 1
    while n:
        l.append(a)
        l.append(a)
        a += 2
        n -= 1
    if b:
        l.append(a)
    for i in l:
        print(i, end = ' ')
    t -= 1


t = int(input())
while t:
    l = []
    n = int(input())
    b = n % 2
    n = n // 2
    a = 1
    while n:
        l.append(a)
        l.append(a)
        a += 2
        n -= 1
    if b:
        l.append(a)
    for i in l:
        print(i, end = ' ')
    print('\n')
    t -= 1


t = int(input())
while t:
    l = []
    n = int(input())
    b = n % 2
    n = n // 2
    a = 1
    while n:
        l.append(str(a))
        l.append(str(a))
        a += 2
        n -= 1
    if b:
        l.append(str(a))
    print(" ".join(l))
    t -= 1


t = int(input())
while t:
    l = []
    n = int(input())
    b = n % 2
    n = n // 2
    a = 1
    while n:
        l.append(a)
        l.append(a)
        a += 2
        n -= 1
    if b:
        l.append(a)
    print(l)


for _ in range(int(input())):
    n=int(input())
    cnt=999
    for i in range(n):
        print(cnt,end=" ")


for _ in range(int(input())):
    n=int(input())
    cnt=999
    for i in range(n):
        print(cnt,end=" ")
        cnt-=1
    print()


for _ in range(int(input())):
    n=int(input())
    cnt=999
    for i in range(n):
        print(cnt,end=" ")
    print()


for _ in range(int(input())):
    n=int(input())
    cnt=999
    for i in range(n):
        print(cnt,end=" ")
        cnt-=1


t=int(input())
while(t>0):
    n=[]
    m=int(input())
    for i in range(m):
        n.append('1')
    print(' '.join(n))
    t-=1


t=int(input())
while(t>0):
    m=int(input())
    n=[]
    n.append(str(2))
    n.append(str(1))
    for i in range(1,m):
        n.append(str(int(n[i])+int(n[i-1])+1))
    n.remove(n[0])
    print(' '.join(n))
    t-=1


t=int(input())
while(t>0):
    m=int(input())
    n=[]
    n.append(str(1))
    n.append(str(2))
    for i in range(1,m):
        n.append(str(int(n[i])+int(n[i-1])+1))
    n.remove(n[0])
    print(' '.join(n))
    t-=1


for x in range(int(input())):
    l=int(input())
    lst=list()
    k=999
    while(l>=1):

        lst.append(k)
        k=k-50
        l=l-1
    print(*lst)


for x in range(int(input())):
    l=int(input())
    lst=list()
    k=999
    while(l>=0):

        lst.append(k)
        k=k-50
        l=l-1
    print(*lst)


for x in range(int(input())):
    l=int(input())
    lst=list()
    k=1
    while(l>=1):

        lst.append(k)

        l=l-1
    print(*lst)


def func(n):
    return ' '.join(['1' for i in range(n)])

def main():
    t = int(input())
    input_list = [int(input()) for i in range(t)]
    for i in list(map(func,input_list)):
        print(i)

main()


def func(n):
    if n == 1:
        return '1'
    if n == 2:
        return '1 2'
    li = [1,2]
    while len(li) < n:
        li.append(li[-1]+li[-2]+1)
    return ' '.join(list(map(str,li)))

def main():
    t = int(input())
    input_list = [int(input()) for i in range(t)]
    for i in list(map(func,input_list)):
        print(i)

main()


def func(n):
    num = 1
    li = []
    while len(li) < n:
        li.append(num)
        num += 2
    return ' '.join(list(map(str,li)))

def main():
    t = int(input())
    input_list = [int(input()) for i in range(t)]
    for i in list(map(func,input_list)):
        print(i)

main()


for _ in range(int(input())):
    n=int(input())
    i=0;lists=[1]
    while i<n-1:
        lists.append(1)
        i=i+1
    print(*lists)


for _ in range(int(input())):
    n=int(input())
    i=0;lists=[1]
    while i<n-1:
        lists.append(lists[i]+2)
        i=i+1
    print(*lists)


for _ in range(int(input())):
    n=int(input())
    i=0;lists=[1]
    while i<n:
        lists.append(lists[i]+2)
        i=i+1
    print(*lists)


for _ in range(int(input())):
    n=int(input())
    i=0;lists=[1]
    while i<n:
        lists.append(lists[i]+2)
        i=i+1


n=int(input())
for i in range(n):
    m=int(input())
    for i in range(m):
        print(1,end=' ')
    print('\n')


n=int(input())
for i in range(n):
    m=int(input())
    for i in range(1,m+1):
        print(i+1,end=' ')
    print('\n')


n=int(input())
for i in range(n):
    m=int(input())
    for i in range(1,m+1):
        print(1,end='')
    print()


n=int(input())
for i in range(n):
    m=int(input())
    for i in range(1,m+1):
        print(i+1,end=' ')


n=int(input())
for i in range(n):
    m=int(input())
    for i in range(1,m+1):
        print(1,end=' ')
    print()


for _ in range(int(input())):
    t=[i for i in range(0,1000)]
    r=int(input())
    a=[]
    for i in range(r):
        if i==0:
            a.append(1)
        elif i==1:
            a.append(2)
        else:
            x=a[-1]+a[-2]
            t=t[x+1:]
            a.append(t[0])
    for i in a:
        print(i,end='')


for _ in range(int(input())):
    n=int(input())
    for i in range(n):
        print(1,end=' ')
    print()


for _ in range(int(input())):
    t=[i for i in range(0,1000)]
    r=int(input())
    a=[]
    for i in range(r):
        if i==0:
            a.append(1)
        elif i==1:
            a.append(2)
        else:
            x=a[-1]+a[-2]
            t=t[x+1:]
            a.append(t[0])
    for i in a:
        print(i,end='')
    print()


for _ in range(int(input())):
    t=[i for i in range(0,1000)]
    r=int(input())
    a=[]
    for i in range(r):
        if i==0:
            a.append(1)
        elif i==1:
            a.append(2)
        else:
            x=a[-1]+a[-2]
            t=t[x+1:]
            a.append(t[0])
    for i in a:
        print(i,end=' ')
    print()


for _ in range(int(input())):
    n=int(input())
    for i in range(n):
        print(1,end=" ")
    print("")


for _ in range(int(input())):
    n=int(input())
    for i in range(n):
        print(1,end=" ")


for _ in range(int(input())):
    n=int(input())
    x=1000//n
    z=[x for i in range(n)]
    print([x for i in range(n)])


for _ in range(int(input())):
    n=int(input())
    print([1000//n for i in range(n)])


z=input
mod = 10**9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
def lcd(xnum1,xnum2):
    return (xnum1*xnum2//gcd(xnum1,xnum2))

################################################################################

"""

n=int(z())

for i in range(int(z())):

for i in range(int(z())):

x=int(z())

l=list(map(int,z().split()))

a,b=map(int,z().split())

l=set(map(int,z().split()))

led=(6,2,5,5,4,5,6,3,7,6)

vowel={'a':0,'e':0,'i':0,'o':0,'u':0}

color-4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ]

"""

###########################---START-CODING---###############################################

for i in range(int(z())):
    x=int(z())
    l=[]
    j=1
    s=2
    d=1000
    for i in range(1,x+1):
        l.append(i+j+100+s+d)
        j+=1
        d-1
    print(*l)


z=input
mod = 10**9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
def lcd(xnum1,xnum2):
    return (xnum1*xnum2//gcd(xnum1,xnum2))

################################################################################

"""

n=int(z())

for i in range(int(z())):

for i in range(int(z())):

x=int(z())

l=list(map(int,z().split()))

a,b=map(int,z().split())

l=set(map(int,z().split()))

led=(6,2,5,5,4,5,6,3,7,6)

vowel={'a':0,'e':0,'i':0,'o':0,'u':0}

color-4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ]

"""

###########################---START-CODING---###############################################

for i in range(int(z())):
    x=int(z())
    l=[]
    j=1
    for i in range(1,x+1):
        l.append(i+j)
        j+=1
    print(*l)


z=input
mod = 10**9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
def lcd(xnum1,xnum2):
    return (xnum1*xnum2//gcd(xnum1,xnum2))

################################################################################

"""

n=int(z())

for i in range(int(z())):

for i in range(int(z())):

x=int(z())

l=list(map(int,z().split()))

a,b=map(int,z().split())

l=set(map(int,z().split()))

led=(6,2,5,5,4,5,6,3,7,6)

vowel={'a':0,'e':0,'i':0,'o':0,'u':0}

color-4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ]

"""

###########################---START-CODING---###############################################

for i in range(int(z())):
    x=int(z())
    l=[]
    j=1
    for i in range(1,x+1):
        l.append(i+j+100)
        j+=1
    print(*l)


z=input
mod = 10**9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
def lcd(xnum1,xnum2):
    return (xnum1*xnum2//gcd(xnum1,xnum2))

################################################################################

"""

n=int(z())

for i in range(int(z())):

for i in range(int(z())):

x=int(z())

l=list(map(int,z().split()))

a,b=map(int,z().split())

l=set(map(int,z().split()))

led=(6,2,5,5,4,5,6,3,7,6)

vowel={'a':0,'e':0,'i':0,'o':0,'u':0}

color-4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ]

"""

###########################---START-CODING---###############################################

for i in range(int(z())):
    x=int(z())
    l=[]
    j=1
    for i in range(1,x+1):
        l.append(i+j+100))
        j+=1
    print(*l)


z=input
mod = 10**9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
def lcd(xnum1,xnum2):
    return (xnum1*xnum2//gcd(xnum1,xnum2))

################################################################################

"""

n=int(z())

for i in range(int(z())):

for i in range(int(z())):

x=int(z())

l=list(map(int,z().split()))

a,b=map(int,z().split())

l=set(map(int,z().split()))

led=(6,2,5,5,4,5,6,3,7,6)

vowel={'a':0,'e':0,'i':0,'o':0,'u':0}

color-4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ]

"""

###########################---START-CODING---###############################################

for i in range(int(z())):
    x=int(z())
    l=[]
    j=1
    s=2
    d=100
    for i in range(1000,1000-x,-1):
        l.append(2)
    print(*l)


z=input
mod = 10**9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
def lcd(xnum1,xnum2):
    return (xnum1*xnum2//gcd(xnum1,xnum2))

################################################################################

"""

n=int(z())

for i in range(int(z())):

for i in range(int(z())):

x=int(z())

l=list(map(int,z().split()))

a,b=map(int,z().split())

l=set(map(int,z().split()))

led=(6,2,5,5,4,5,6,3,7,6)

vowel={'a':0,'e':0,'i':0,'o':0,'u':0}

color-4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ]

"""

###########################---START-CODING---###############################################

for i in range(int(z())):
    x=int(z())
    l=[]
    j=1
    s=0
    d+=1000
    for i in range(1,x+1):
        l.append(i+j+100+s+d)
        j+=1
        d-1
    print(*l)


z=input
mod = 10**9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
def lcd(xnum1,xnum2):
    return (xnum1*xnum2//gcd(xnum1,xnum2))

################################################################################

"""

n=int(z())

for i in range(int(z())):

for i in range(int(z())):

x=int(z())

l=list(map(int,z().split()))

a,b=map(int,z().split())

l=set(map(int,z().split()))

led=(6,2,5,5,4,5,6,3,7,6)

vowel={'a':0,'e':0,'i':0,'o':0,'u':0}

color-4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ]

"""

###########################---START-CODING---###############################################

for i in range(int(z())):
    x=int(z())
    l=[]
    j=1
    for i in range(1,x+1):
        l.append(i+(j*100))
        j+=1
    print(*l)


z=input
mod = 10**9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
def lcd(xnum1,xnum2):
    return (xnum1*xnum2//gcd(xnum1,xnum2))

################################################################################

"""

n=int(z())

for i in range(int(z())):

for i in range(int(z())):

x=int(z())

l=list(map(int,z().split()))

a,b=map(int,z().split())

l=set(map(int,z().split()))

led=(6,2,5,5,4,5,6,3,7,6)

vowel={'a':0,'e':0,'i':0,'o':0,'u':0}

color-4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ]

"""

###########################---START-CODING---###############################################

for i in range(int(z())):
    x=int(z())
    l=[]
    for i in range(1,x+1):
        l.append(i+100)
    print(*l)


z=input
mod = 10**9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
def lcd(xnum1,xnum2):
    return (xnum1*xnum2//gcd(xnum1,xnum2))

################################################################################

"""

n=int(z())

for i in range(int(z())):

for i in range(int(z())):

x=int(z())

l=list(map(int,z().split()))

a,b=map(int,z().split())

l=set(map(int,z().split()))

led=(6,2,5,5,4,5,6,3,7,6)

vowel={'a':0,'e':0,'i':0,'o':0,'u':0}

color-4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ]

"""

###########################---START-CODING---###############################################

for i in range(int(z())):
    x=int(z())
    l=[]
    j=1
    s=2
    d=100
    for i in range(1,x+1):
        l.append(i+j+100+s+d)
        j+=1
        d-1
    print(*l)