#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
    if (a == 0) return b;
    else return gcd(b % a, a);
}

int32_t main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,fpb,sum=1, now; cin >> n;
    ll a[n];
    for (int i=0; i<n;i++){
    	cin >> a[i];
	}
	fpb=a[0];
	for (int i=0; i<n;i++){
		fpb=gcd(fpb,a[i]);
	}
	cerr << fpb << '\n';
	if (fpb>1) sum++;
	for (ll i=2; i*i<=fpb;i++){
		if (fpb%i==0){
			sum+=2;
			if (i*i==fpb){
				sum--;
			}
		}
	}
	cout << sum;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int main(){
    ll n; cin >> n;
    ll a[n];
    cin >> a[0];
    ll fpb = a[0];
    for (ll i=1; i<n; i++) {
    	ll k; cin >> k;
    	fpb = gcd(fpb,k);
	}

	ll cek[fpb+1];
	for (ll i =0;i<=fpb;i++){
		cek[i]=1;
	}
	for (ll i=2;i<=fpb/2;i++){
		for (ll j=2*i;j<=fpb;j+=i){
			cek[j]=0;
		}
	}

	ll sum =0;
	for (ll i=1;i<=fpb;i++){
		sum += cek[i];
	}
	cout <<sum;
}


#include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int main(){
    int n; cin >> n;
    int a[n];
    cin >> a[0];
    int fpb = a[0];
    for (int i=1; i<n; i++) {
    	int k; cin >> k;
    	fpb = gcd(fpb,k);
	}

	int cek[fpb+1];
	for (int i =0;i<=fpb;i++){
		cek[i]=1;
	}
	for (int i=2;i<=fpb/2;i++){
		for (int j=2*i;j<=fpb;j+=i){
			cek[j]=0;
		}
	}

	int sum =0;
	for (int i=1;i<=fpb;i++){
		sum += cek[i];
	}
	cout <<sum;
}


#include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b) {
    if (a == 0){
        return b;
	}
    return gcd(b % a, a);
}

int main(){
    int n; cin >> n;
    int a[n];
    cin >> a[0];
    int fpb = a[0];
    for (int i=1; i<n; i++) {
    	int k; cin >> k;
    	fpb = gcd(fpb,k);
	}
	int sum =0;
	for (int i =1; i<=fpb;i++){
		if (fpb%i==0){
			sum ++;
		}
	}
	cout <<sum;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
    int c;
	while(b){
    	c = a%b;	a = b;b = c;
	}
	return a;
}

int main(){
    ll a,n, now=0; cin >> n;
    for (ll i=0; i<n;i++){
    	cin >> a;
    	now=gcd(a,now);
	}
	ll d=2, ans=1;
	while(now != 1){
		int prime = 0;
		while(now%d == 0){
			now /= d; prime ++;
		}
		ans *= prime+1;
		d++;
	}
	cout << ans;
}


#include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int main(){
    int n; cin >> n;
    int a[n];
    cin >> a[0];
    int fpb = a[0];
    for (int i=1; i<n; i++) {
    	int k; cin >> k;
    	fpb = gcd(fpb,k);
	}
	int sum =0;
	for (int i =1; i<=fpb;i++){
		if (fpb%i==0){
			sum ++;
		}
	}
	cout <<sum;
}


#include <bits/stdc++.h>
using namespace std;

int gcd(long long int a, long long int b) {
    if (a == 0) return b;
    else return gcd(b % a, a);
}

int main(){
    long long int n,fpb,sum=0; cin >> n; cin >> fpb;
    for (int i=1; i<n; i++) {
    	int k; cin >> k;fpb = gcd(fpb,k);
	}
	for (int i =1; i<=fpb;i++){
		if (fpb%i==0)sum ++;
	}
	cout <<sum;
}


#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <queue>
using namespace std;
long long gcd(long long a,long long b)
{
    return b?gcd(b,a%b):a;
}
int main()
{
    int t,n,k;
    while(~scanf("%d",&n))
    {
        long long a,b;
        for(int i=1; i<=n; i++)
        {
            scanf("%I64d",&b);
            if(i==1)
            {
                a=b;
            }
            else
            {
                a=gcd(a,b);
            }
        }
        long long num=0;
        long long s=sqrt(a);
        if(a==s*s)
            num=-1;
        for(int i=1; i<=s; i++)
        {
            if(a%i==0)
                num+=2;
        }

        printf("%I64d\n",num);
    }
    return 0;
}
//2019-08-15 20:38:36.259


#include<stdio.h>
using namespace std;
long long str[400005];
long long gcd(long long a,long long b)
{
    return b==0?a:gcd(b,a%b);
}
long long get(long long x)
{
    long long sum=0;
    for(long long  i=1; i*i<=x; i++)
    {
        if(x%i==0)
        {
            sum++;
            if(x/i!=i)
            sum++;
        }
    }
    return sum;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%I64d",&str[i]);
    }
    long long gcd1=str[1];
    for(int i=1; i<=n; i++)
    {
        gcd1=gcd(str[i],gcd1);
    }
    long long ans=get(gcd1);
    printf("%I64d\n",ans);
    return 0;
}
//2019-08-15 19:35:05.537


#include<bits/stdc++.h>
using namespace std;
long long n;
long long gcd(long long a,long long b)
{
    if (!b) return a;
    return gcd(b,a%b);
}
void solve()
{
    long long i,a[n],res=a[0],ans=0;
    for (i=0;i<n;i++)
        cin>>a[i];
    for (i=0;i<n;i++)
        res=gcd(res,a[i]);
    for (i=1;i*i<=res;i++)
        if (res%i==0) ans+=2;
    if ((i-1)*(i-1)==res) ans--;
    cout<<ans<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}//2019-08-15 19:49:24.158


#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<math.h>
using namespace std;
typedef long long ll;
const int inf=0x7f7f7f;
ll a[400005];
int main()
{
    ll n;
    scanf("%I64d",&n);
    for(ll i=1;i<=n;i++)
    {
        scanf("%I64d",&a[i]);
    }
    sort(a+1,a+n+1);
    ll num=a[1];
    for(ll i=2;i<=n;i++)
    {
        while(a[i]%num!=0)
        {
            ll con=a[i]%num;
            a[i]=num;
            num=con;
        }
    }
    ll sum=0;
    for(ll i=1;i<=sqrt(num);i++)
    {
        ll o=num/i;
        if(o*i==num)
        {
            if(o==i)
            {
                sum++;
            }
            else sum+=2;
        }
    }
    printf("%I64d\n",sum);
    return 0;
}
//2019-08-15 20:40:45.877


#include<stdio.h>
#include<string.h>
typedef long long ll;
ll a[400005],vis[400005],prime[400005],tot=0;
ll gcd(ll a,ll b)
{
    return b==0? a:gcd(b,a%b);
}
ll check(ll n)
{
    int flag=0;
        for(ll i=1;i*i<=n;i++)
        {
            if(n%i==0)
            {
                tot++;
            }
            if(i*i==n)
            {
                flag=1;
            }
        }

            if(flag)
        {
            return tot*2-1;
        }
        return tot*2;
}
int main()
{
    ll n;
    scanf("%I64d",&n);
    scanf("%I64d",&a[1]);
    ll d=a[1];
    for(int i=2;i<=n;i++)
    {
        scanf("%I64d",&a[i]);
        d=gcd(d,a[i]);
    }
    printf("%I64d",check(d));
    return 0;
}
//2019-08-15 20:47:49.061


#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;
long long  s1[40005];
typedef long long ll;
int n;
int main()
{
    int t,n;
    scanf("%d",&n);
    scanf("%I64d",&s1[1]);
    ll g=s1[1];
    ll ans=0;
    for(int i=2; i<=n; i++)
    {
         scanf("%I64d",&s1[i]);
         g=__gcd(g,s1[i]);
    }
    for(int i=1;i<=g;i++)
    {
        if(g%i==0)
            ans++;
    }
    printf("%I64d\n",ans);
    return 0;
}

//2019-08-15 20:28:10.501


#include<bits/stdc++.h>
using namespace std;
long long n;
long long gcd(long long a,long long b)
{
    if (!b) return a;
    return gcd(b,a%b);
}
void solve()
{
    long long i,a[n],res=a[0],ans=0;
    for (i=0;i<n;i++)
        cin>>a[i];
    for (i=0;i<n;i++)
        res=gcd(res,a[i]);
    for (i=1;i<=res;i++)
        if (res%i==0) ans+=2;
    if ((i-1)*(i-1)==res) ans--;
    cout<<ans<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}//2019-08-15 19:46:44.24


#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

const int N = 4e5+5;

typedef long long LL;

LL a[N];

LL gcd(LL a,LL b)
{
    if(!b)return a;
    gcd(b,a%b);
}

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

    cin >> n;

    for(int i=0;i<n;i++)
        cin >> a[i];

    LL t=a[0];

    for(int i=1;i<n;i++)
        t=gcd(t,a[1]);

    int res=0;

    for(int i=1;i<=t;i++)
    {
        bool flag=0;
        for(int j=0;j<n;j++)
        {
            if(a[j]%i!=0)
            {
                flag=1;
                break;
            }
        }
        if(!flag)
            res++;
    }

    cout << res <<endl;

    return 0;
}

//2019-08-15 19:17:39.999


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;

const int N = 4e5+5;

typedef long long LL;

LL a[N];

LL gcd(LL a,LL b)
{
    if(!b)return a;
    gcd(b,a%b);
}

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

    cin >> n;

    for(int i=0; i<n; i++)
        cin >> a[i];

    LL t=a[0];

    for(int i=1; i<n; i++)
        t=gcd(t,a[i]);

    int res=0;

    for(LL i=1;i<=t;i++)
    {
        if(t%i==0)
            res++;
    }

    cout << res <<endl;

    return 0;
}

//2019-08-15 20:13:50.04


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,gcd,x;
    cin>>n;
    cin>>gcd;
    for(int i=2;i<=n;i++)
    {
        cin>>x;
        gcd=__gcd(gcd,x);
    }
    ll ans=0;
    for(int i=1;i*i<=gcd;i++)
    {

        if(gcd%i==0)
        {
            ans++;
            if(i*i!=gcd)
                ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}
//2019-08-15 19:04:28.88


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;

const int N = 4e5+5;

typedef long long LL;

LL a[N];

LL gcd(LL a,LL b)
{
    if(!b)return a;
    gcd(b,a%b);
}

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

    cin >> n;

    for(int i=0; i<n; i++)
        cin >> a[i];

    LL t=a[0];

    for(int i=1; i<n; i++)
        t=gcd(t,a[i]);

    if(t==1)
    {
        cout << "1" << endl;
        return 0;
    }

    int res=0;
    int m = sqrt(t);

    for(LL i=1;i<=m;i++)
    {
        if(t%i==0)
            res++;
    }

    cout << res*2 <<endl;

    return 0;
}

//2019-08-15 20:18:09.924


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;

const int N = 4e5+5;

typedef long long LL;

LL a[N];

LL gcd(LL a,LL b)
{
    if(!b)return a;
    gcd(b,a%b);
}

int main()
{
    int n;

    ios::sync_with_stdio(false);

    cin >> n;

    for(int i=0; i<n; i++)
        cin >> a[i];

    LL t=a[0];

    for(int i=1; i<n; i++)
        t=gcd(t,a[i]);

    if(t==1)
    {
        cout << "1" << endl;
        return 0;
    }

    LL res=1;
    LL m =(int) sqrt(t);

    for(LL i=2; i<=m; i++)
    {
        if(t%i==0)
        {
            int d=0;
            while(t%i==0)
            {
                t/=i;
                d++;
            }
            res=res*(d+1);
        }
    }
    if(t>1)
        res=res*2;

    cout << res <<endl;

    return 0;
}

//2019-08-15 20:41:53.835


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
    ll r = 1;
    while(b)
    {
        r = a%b;
        a = b;
        b = r;
    }
    return a;
}
ll a[400005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
    }
    ll x=a[0],ans=0;
    for(int i=1;i<n;i++)
    {
        x=gcd(x,a[i]);
    }
    for(int i=1;i<sqrt(x);i++)
    {
        if(x%i==0)
            ans+=2;
    }
    if(sqrt(x)*sqrt(x)==x)
        ans+=1;
    printf("%I64d\n",ans);
    return 0;
}
//2019-08-15 20:13:07.548


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll N=4e5+5;
ll n;
ll a[N];
ll temp,hh;
ll res;
ll gcd(ll a,ll b)
{
    while(b)
    {
        ll temp=a;
        a=b;
        b=temp%b;
    }
    return a;
}
int main()
{
    res=0;
    scanf("%I64d",&n);
    for(register ll i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
    }
    sort(a,a+n);
    temp=a[0];
    hh=sqrt(temp);
    for(register ll i=1;i<=hh;i++)
    {
        ll ans=0,ans1=0;
        if(temp%i==0)
        {
        ll pp=temp/i;
        for(register ll j=0;j<n;j++)
        {
            if(a[j]%i==0)
            {
                ans++;
            }
            if(pp!=i&&a[j]%pp==0)
                ans1++;
        }
        if(ans==n)
        {
            res++;
        }
        if(ans1==n)
            res++;
        }
    }
    printf("%I64d\n",res);
    return 0;
}
//2019-08-15 20:54:51.088


#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <queue>
using namespace std;
vector<int>v;
int vis[10005];
long long gcd(long long a,long long b)
{
    return b? gcd(b,a%b):a;
}
int main()
{
    int t,n,k;
    long long arr[50005];
    while(~scanf("%d",&n))
    {
        long long a,b;
        for(int i=1; i<=n; i++)
        {
            scanf("%I64d",&arr[i]);
            if(i==1)
            {
                a=arr[i];
            }
            else
            {
                b=arr[i];
                if(a%b==0)
                    continue;
                a=gcd(a,b);
            }
        }
        long long num=0;
        long long s=sqrt(a);
        for(int i=1; i<=s; i++)
        {
            if(a%i==0)
                num+=2;
        }
        if(a==s*s&&a%s==0)
            num--;
        printf("%I64d\n",num);
    }
    return 0;
}
//2019-08-15 20:27:08.209


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
    ll r = 1;
    while(b)
    {
        r = a%b;
        a = b;
        b = r;
    }
    return a;
}
ll a[400005];
int main()
{
    int n,ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
    }
    ll x=a[0];
    for(int i=1;i<n;i++)
    {
        x=gcd(x,a[i]);
    }
    for(int i=1;i<sqrt(x);i++)
    {
        if(x%i==0)
            ans+=2;
    }
    if(sqrt(x)*sqrt(x)==x)
        ans+=1;
    printf("%d\n",ans);
    return 0;
}
//2019-08-15 20:08:01.323


#include<stdio.h>
#include<algorithm>
using namespace std;
long long str[400005];
long long get(long long x)
{
    long long sum=0;
    for(int i=1; i*i<=x; i++)
    {
        if(x%i==0)
        {
            sum++;
            if(x/i!=i)
                sum++;
        }
    }
    return sum;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%I64d",&str[i]);
    }
    long long gcd=str[1];
    for(int i=1; i<=n; i++)
    {
        gcd=__gcd(str[i],gcd);
    }
    long long ans=get(gcd);
    printf("%I64d\n",ans);
    return 0;
}
//2019-08-15 19:32:11.893


#include<stdio.h>
#include<string.h>
int a[400005],vis[400005],prime[400005];
int gcd(int a,int b)
{
    return b==0? a:gcd(b,a%b);
}
int check(int d)
{
    memset(vis,0,sizeof(vis));
    int tot=0;
    for(int i=2; i<d; i++)
    {
        if(!vis[i])
        {
            prime[tot++]=i;
        }
        for(int j=0; j<tot; j++)
        {
            if(i*prime[j]>d)
                break;
            vis[i*prime[j]]=1;
            if(i%prime[j]==0)
            {
                break;
            }
        }
    }
    return tot;
}
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%d",&a[1]);
    int d=a[1];
    for(int i=2;i<=n;i++)
    {
        scanf("%d",&a[i]);
        d=gcd(d,a[i]);
    }
    printf("%d",check(d)+1);
    return 0;
}
//2019-08-15 19:53:01.76


#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;
long long  s1[400005];
typedef long long ll;
int n;
int main()
{
    int t,n;
    scanf("%d",&n);
    scanf("%I64d",&s1[1]);
    ll g=s1[1];
    ll ans=0;
    for(int i=2; i<=n; i++)
    {
         scanf("%I64d",&s1[i]);
         g=__gcd(g,s1[i]);
    }
    for(long long i=1;i*i<=g;i++)
    {
        if(g%i==0)
        {
            if(i*i==g)
             ans++;
             else
             ans+=2;
        }

    }
    printf("%I64d\n",ans);
    return 0;
}
//2019-08-15 20:40:07.276


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;

const int N = 4e5+5;

typedef long long LL;

LL a[N];

LL gcd(LL a,LL b)
{
    if(!b)return a;
    gcd(b,a%b);
}

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

    cin >> n;

    for(int i=0; i<n; i++)
        cin >> a[i];

    LL t=a[0];

    for(int i=1; i<n; i++)
        t=gcd(t,a[i]);

    if(t==1)
    {
        cout << "1" << endl;
        return 0;
    }

    LL res=0;
    LL m =(int) sqrt(t);

    for(LL i=1;i<=m;i++)
    {
        if(t%i==0)
            res++;
    }

    cout << res*2 <<endl;

    return 0;
}

//2019-08-15 20:22:17.283


#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<math.h>
using namespace std;
typedef long long ll;
const int inf=0x7f7f7f;
ll a[400005];
int main()
{
    int n;
    scanf("%I64d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a+1,a+n+1);
    ll num=a[1];
    for(int i=2;i<=n;i++)
    {
        while(a[i]%num!=0)
        {
            ll con=a[i]%num;
            a[i]=num;
            num=con;
        }
    }
    int sum=0;
    for(ll i=1;i<=sqrt(num);i++)
    {
        ll o=num/i;
        if(o*i==num)
        {
            if(o==i)
            {
                sum++;
            }
            else sum+=2;
        }
    }
    printf("%d\n",sum);
    return 0;
}
//2019-08-15 20:35:19.451


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;

const int N = 4e5+5;

typedef long long LL;

LL a[N];

LL gcd(LL a,LL b)
{
    if(!b)return a;
    gcd(b,a%b);
}

int main()
{
    int n;

    ios::sync_with_stdio(false);

    cin >> n;

    for(int i=0; i<n; i++)
        cin >> a[i];

    LL t=a[0];

    for(int i=1; i<n; i++)
        t=gcd(t,a[i]);

    if(t==1)
    {
        cout << "1" << endl;
        return 0;
    }

    LL res=0;
    LL m =(int) sqrt(t);

    for(LL i=2; i<=m; i++)
    {
        while(i!=t)
        {
            if(t%i==0)
            {
                res++;
                t/=i;
            }
            else
                break;
        }
    }

    cout << (res+1)*2 <<endl;

    return 0;
}

//2019-08-15 20:29:54.031


#include<bits/stdc++.h>
using namespace std;
long long n;
long long gcd(long long a,long long b)
{
    return !b?a:gcd(b,a%b);
}
void solve()
{
    long long i,a[n],res,ans=0;
    for (i=0;i<n;i++)
        cin>>a[i];
    res=a[0];
    for (i=1;i<n;i++)
        res=gcd(res,a[i]);
    for (i=1;i*i<=res;i++)
        if (res%i==0) ans+=2;
    if ((i-1)*(i-1)==res) ans--;
    cout<<ans<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}//2019-08-15 20:03:08.527


#include "stdio.h"
#include "algorithm"
using namespace std;
long long n,g,k,ans,a[400005];
int main()
{
    scanf("%I64d%I64d",&n,&a[1]);
    g=a[1];
    for(int i=2;i<=n;i++)
    {
        scanf("%I64d", &a[i]);
        g=__gcd(g,a[i]);
    }
    for(long long i=1;i*i<=g;i++)
    {
        if(g%i==0)
        {
            k=g/i;
            if(k==i)
                ans++;
            else
                ans+=2;
        }
    }
    printf("%I64d\n",ans);
    return 0;
}//2019-08-15 19:27:27.091


#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;
long long  s1[400005];
typedef long long ll;
int n;
int main()
{
    int t,n;
    scanf("%d",&n);
    scanf("%I64d",&s1[1]);
    ll g=s1[1];
    ll ans=0;
    for(int i=2; i<=n; i++)
    {
         scanf("%I64d",&s1[i]);
         g=__gcd(g,s1[i]);
    }
    for(int i=1;i*i<=g;i++)
    {
        if(g%i==0)
        {
            if(i*i==g)
             ans++;
             else
                ans+=2;
        }

    }
    printf("%I64d\n",ans);
    return 0;
}
//2019-08-15 20:34:13.438


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 4e5+5;
const ll INF = 1e12+2;
ll a[maxn];
//ll p[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	ll ans = 0;
	ll sml = INF;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		if(a[i]<sml) sml = a[i];
	}
	//memset(p,0,sizeof(p));
	map<ll,int>m;
		ll tmp = sml;
		for(int j=1;1LL*j*j<=tmp;j++)
		{
			if(tmp%j==0)
			{
				if(j!=tmp/j)
				{
					m[j]++;

					m[tmp/j]++;
				}
				else m[j]++;
			}
		}
	for(int i=1;i<=n;i++)
	{
		auto it = m.begin();
		for(;it!=m.end();it++)
		{
			ll p = it->first;
			if(a[i]%p==0) m[p]++;
		}

		if(i==n)
		{
			auto it = m.begin();
			for( ;it!=m.end();it++)
			{
				int p = it->second;
				if(p==n+1) ans++;
			}
		}
	}

	printf("%lld\n",ans);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 4e5+5;

ll a[maxn];
//ll p[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	ll ans = 0;

	ll gcd = 0;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		gcd = __gcd(gcd,a[i]);
	}

	for(int i=1;i*i<=gcd;i++)
	{
		if(gcd%i==0)
		{
			if(gcd/i !=i) ans+=2;
			else ans++;
		}
	}

	printf("%lld\n",ans);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 4e5+5;

ll a[maxn];
//ll p[maxn];
int main()
{
	int n;
	cin>>n;
	ll ans = 0;
	//memset(p,0,sizeof(p));
	map<ll,int>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		ll tmp = a[i];
		for(int j=1;1LL*j*j<=tmp;j++)
		{
			if(tmp%j==0)
			{
				if(j!=tmp/j)
				{
					m[j]++;

					m[tmp/j]++;
				}
				else m[j]++;
			}
		}
		if(i==n)
		{
			auto it = m.begin();
			for( ;it!=m.end();it++)
			{
				int p = it->second;
				if(p==n) ans++;
			}
		}
	}

	 cout<<ans<<"\n";
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 4e5+5;
const ll INF = 1e12+2;
ll a[maxn];
//ll p[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	ll ans = 0;

	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	ll gcd = __gcd(a[0],a[1]);
	for(int i=2;i<n;i++)
	{
		gcd = __gcd(gcd,a[i]);
	}

	for(int i=1;i*i<=gcd;i++)
	{
		if(gcd%i==0)
		{
			if(gcd/i !=i) ans+=2;
			else ans++;
		}
	}

	printf("%lld\n",ans);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 4e5+5;

ll a[maxn];
//ll p[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	ll ans = 0;
	//memset(p,0,sizeof(p));
	map<ll,int>m;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		ll tmp = a[i];
		for(int j=1;1LL*j*j<=tmp;j++)
		{
			if(tmp%j==0)
			{
				if(j!=tmp/j)
				{
					m[j]++;

					m[tmp/j]++;
				}
				else m[j]++;
			}
		}

		if(i==n)
		{
			auto it = m.begin();
			for( ;it!=m.end();it++)
			{
				int p = it->second;
				if(p==n) ans++;
			}
		}
	}

	printf("%lld\n",ans);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 4e5+5;

int main()
{
	int n;
	while(~scanf("%d",&n))
	{

	ll ans = 0;

	ll gcd = 0;
	for(int i=0;i<n;i++)
	{
		ll x ;
		scanf("%lld",&x);
		gcd = __gcd(gcd,x);
	}

	for(int i=1;1LL*i*i<=gcd;i++)
	{
		if(gcd%i==0)
		{
			if(gcd/i !=i) ans+=2;
			else ans++;
		}
	}

	printf("%lld\n",ans);}
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 4e5+5;
ll a[maxn];
int main()
{
	int n;
	while(~scanf("%d",&n))
	{

	ll ans = 0;

	ll gcd = 0;
	for(int i=0;i<n;i++)
	{

		scanf("%lld",&a[i]);
		gcd = __gcd(gcd,a[i]);
	}

	for(int i=1;1LL*i*i<=gcd;i++)
	{
		if(gcd%i==0)
		{
			if(gcd/i !=i) ans+=2;
			else ans++;
		}
	}

	printf("%lld\n",ans);}
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 4e5+5;

int main()
{
	int n;
	while(~scanf("%d",&n))
	{

	int ans = 0;

	ll gcd = 0;
	for(int i=0;i<n;i++)
	{
		ll x ;
		scanf("%lld",&x);
		gcd = __gcd(gcd,x);
	}

	for(int i=1;1LL*i*i<=gcd;i++)
	{
		if(gcd%i==0)
		{
			if(gcd/i !=i) ans+=2;
			else ans++;
		}
	}

	printf("%d\n",ans);}
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 4e5+5;

int main()
{
	int n;
	while(~scanf("%d",&n))
	{

	int ans = 0;

	ll gcd = 0;
	for(int i=0;i<n;++i)
	{
		ll x ;
		scanf("%lld",&x);
		gcd = __gcd(gcd,x);
	}

	for(int i=1;1LL*i*i<=gcd;++i)
	{
		if(gcd%i==0)
		{
			if(gcd/i !=i) ans+=2;
			else ans++;
		}
	}

	printf("%d\n",ans);}
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 4e5+5;

ll a[maxn];
//ll p[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	ll ans = 0;
	//memset(p,0,sizeof(p));
	map<ll,int>m;
		scanf("%lld",&a[1]);
		ll tmp = a[1];
		for(int j=1;1LL*j*j<=tmp;j++)
		{
			if(tmp%j==0)
			{
				if(j!=tmp/j)
				{
					m[j]++;

					m[tmp/j]++;
				}
				else m[j]++;
			}
		}
	for(int i=2;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		auto it = m.begin();
		for(;it!=m.end();it++)
		{
			ll p = it->first;
			if(a[i]%p==0) m[p]++;
		}
		if(i==n)
		{
			auto it = m.begin();
			for( ;it!=m.end();it++)
			{
				int p = it->second;
				if(p==n) ans++;
			}
		}
	}

	printf("%lld\n",ans);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 4e5+5;

int main()
{
	int n;
	scanf("%d",&n);
	int ans = 0;

	ll gcd = 0;
	for(int i=0;i<n;++i)
	{
		ll x ;
		scanf("%lld",&x);
		gcd = __gcd(gcd,x);
	}

	for(int i=1;1LL*i*i<=gcd;++i)
	{
		if(gcd%i==0)
		{
			if(gcd/i !=i) ans+=2;
			else ans++;
		}
	}

	printf("%lld\n",ans);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 4e5+5;
ll a[maxn];
int main()
{
	int n;
	while(~scanf("%d",&n))
	{

	ll ans = 0;

	ll gcd = 0;
	for(int i=0;i<n;i++)
	{

		scanf("%lld",&a[i]);
		gcd = __gcd(gcd,a[i]);
	}

	for(int i=1;i*i<=gcd;i++)
	{
		if(gcd%i==0)
		{
			if(gcd/i !=i) ans+=2;
			else ans++;
		}
	}

	printf("%lld\n",ans);}
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll numDiv(ll n);

int main() {
	ios::sync_with_stdio(false);
	ll n, k, b;
	cin >> n;
	cin >> k;
	for (int i = 1; i < n; i++) {
		ll a;
		cin >> a;
		k = __gcd(k, a);
	}
	cout << numDiv(k);
	return 0;
}

ll numDiv(ll n) {
	ll ans = 0;
	for (ll i = 1; i * i <= n; i++)
		if (n % i == 0) {
			if (i * i == n)
				ans++;
			else
				ans += 2;
		}
	return ans;
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll numDiv(ll n);

ll n;
ll f[4 * 1000 * 100 + 1];

int main() {
	cin >> n;
	ll p;
	for (ll i = 0; i < n; i++)
		cin >> f[i];
	ll k = f[0];
	for (ll i = 1; i < n; i++) {
		ll k = __gcd(f[i], k);
		p = k;
	}
	cout << numDiv(p);
	return 0;
}

ll numDiv(ll n) {
	if (n == 1)
		return 1;
	ll ans = 1;
	ll p = n;
	for (ll i = 2; i * i <= n; i++)
		while (n % i == 0) {
			n /= i;
			ans++;
		}
	if (n == p)
		return ans + 1;
	return n == 1? ans + 1: ans + 2;
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll numDiv(ll n);

ll n;
ll f[4 * 1000 * 100 + 1];
ll k;

int main() {
	cin >> n;
	cin >> f[0];
	k = f[0];
	for (ll i = 1; i < n; i++) {
		cin >> f[i];
		k = __gcd(k, f[i]);
	}
	cout << numDiv(k);
	return 0;
}

ll numDiv(ll n) {
	if (n == 1)
		return 1;
	ll ans = 1;
	ll p = n;
	for (ll i = 2; i * i <= n; i++)
		while (n % i == 0) {
			n /= i;
			ans++;
		}
	if (n == p)
		return ans + 1;
	return n == 1? ans + 1: ans + 2;
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll numDiv(ll n);

ll const N = 1000 * 1000 * 1000 * 100;
ll n;
ll f[4 * 1000 * 10 + 1];

int main() {
	cin >> n;
	ll maxf = N * N;
	for (ll i = 0; i < n; i++) {
		cin >> f[i];
		if (f[i] < maxf) {
			maxf = f[i];
		}
	}
	ll minG = N * N;
	for (ll i = 0; i < n; i++) {
		ll gcd = __gcd(f[i], maxf);
		if (gcd < minG)
			minG = gcd;
	}
	if (n == 4000000)
		cout << minG << endl;
	cout << numDiv(minG);
	return 0;
}

ll numDiv(ll n) {
	if (n == 1)
		return 1;
	ll ans = 1;
	ll p = n;
	for (ll i = 2; i * i <= n; i++)
		while (n % i == 0) {
			n /= i;
			ans++;
		}
	if (n == p)
		return ans + 1;
	return n == 1? ans + 1: ans + 2;
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll numDiv(ll n);

int main() {
	ios::sync_with_stdio(false);
	ll n, k, b;
	cin >> n;
	cin >> k;
	for (int i = 1; i < n; i++) {
		ll a;
		cin >> a;
		k = __gcd(k, a);
	}
	cout << numDiv(k);
	return 0;
}

ll numDiv(ll n) {
	ll ans = 1;
	for (int i = 2; i * i <= n; i++)
		if (n % i == 0) {
			ll ans2 = 1;
			while (n % i == 0) {
				n /= i;
				ans2++;
			}
			ans *= ans2;
		}
	return n != 1? ans * 2: ans;
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll numDiv(ll n);

ll const N = 1000 * 1001;
ll n;
ll f[4 * 1000 * 10 + 1];

int main() {
	cin >> n;
	for (ll i = 0; i < n; i++)
		cin >> f[i];
	ll gcd = f[0];
	for (ll i = 1; i < n; i++)
		ll gcd = __gcd(f[i], gcd);
	cout << numDiv(gcd);
	return 0;
}

ll numDiv(ll n) {
	if (n == 1)
		return 1;
	ll ans = 1;
	ll p = n;
	for (ll i = 2; i * i <= n; i++)
		while (n % i == 0) {
			n /= i;
			ans++;
		}
	if (n == p)
		return ans + 1;
	return n == 1? ans + 1: ans + 2;
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll numDiv(ll n);

int main() {
	ll n, k, b;
	cin >> n;
	cin >> k;
	for (int i = 1; i < n; i++) {
		ll a;
		cin >> a;
		k = __gcd(k, a);
	}
	cout << numDiv(k);
	return 0;
}

ll numDiv(ll n) {
	ll ans = 1;
	if (n == 1)
		return 1;
	for (int i = 2; i * i <= n; i++)
		if (n % i == 0) {
			ll ans2 = 1;
			while (n % i == 0) {
				n /= i;
				ans2++;
			}
			ans *= ans2;
		}
	return n != 1? ans * 2: ans;
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll numDiv(ll n);

ll const N = 1000 * 1001;
ll n;
ll f[4 * 1000 * 10 + 1];

int main() {
	cin >> n;
	ll maxf = N * N;
	for (ll i = 0; i < n; i++)
		cin >> f[i];
	maxf = f[0];
	ll minG = N * N;
	for (ll i = 1; i < n; i++) {
		ll gcd = __gcd(f[i], maxf);
		if (gcd < minG)
			minG = gcd;
	}
	cout << numDiv(minG);
	return 0;
}

ll numDiv(ll n) {
	if (n == 1)
		return 1;
	ll ans = 1;
	ll p = n;
	for (ll i = 2; i * i <= n; i++)
		while (n % i == 0) {
			n /= i;
			ans++;
		}
	if (n == p)
		return ans + 1;
	return n == 1? ans + 1: ans + 2;
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll numDiv(ll n);

ll const N = 1000 * 1000 * 1000 * 100;
ll n;
ll f[4 * 1000 * 10 + 1];

int main() {
	cin >> n;
	ll maxf = N * N;
	for (ll i = 0; i < n; i++)
		cin >> f[i];

	ll minG = f[0];
	for (ll i = 1; i < n; i++) {
		ll gcd = __gcd(f[i], maxf);
		if (gcd < minG)
			minG = gcd;
	}
	cout << numDiv(minG);
	return 0;
}

ll numDiv(ll n) {
	if (n == 1)
		return 1;
	ll ans = 1;
	ll p = n;
	for (ll i = 2; i * i <= n; i++)
		while (n % i == 0) {
			n /= i;
			ans++;
		}
	if (n == p)
		return ans + 1;
	return n == 1? ans + 1: ans + 2;
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll numDiv(ll n);

ll const N = 1000 * 1000 * 1000 * 100;
ll n;
ll f[4 * 1000 * 10 + 1];

int main() {
	cin >> n;
	ll maxf = N * N;
	for (ll i = 0; i < n; i++)
		cin >> f[i];
	maxf = f[0];
	ll minG = N * N;
	for (ll i = 1; i < n; i++) {
		ll gcd = __gcd(f[i], maxf);
		if (gcd < minG)
			minG = gcd;
	}
	cout << numDiv(minG);
	return 0;
}

ll numDiv(ll n) {
	if (n == 1)
		return 1;
	ll ans = 1;
	ll p = n;
	for (ll i = 2; i * i <= n; i++)
		while (n % i == 0) {
			n /= i;
			ans++;
		}
	if (n == p)
		return ans + 1;
	return n == 1? ans + 1: ans + 2;
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int numDiv(ll n);

ll const N = 1000 * 1000;
int n;
ll f[4 * 1000 * 10 + 1];

int main() {
	cin >> n;
	ll maxf = N;
	for (int i = 0; i < n; i++) {
		cin >> f[i];
		if (f[i] < maxf)
			maxf = f[i];
	}
	ll minG = N;
	for (int i = 0; i < n; i++) {
		ll gcd = __gcd(f[i], maxf);
		if (gcd < minG)
			minG = gcd;
	}
	cout << numDiv(minG);
	return 0;
}

int numDiv(ll n) {
	if (n == 1)
		return 1;
	ll ans = 1;
	ll p = n;
	for (ll i = 2; i * i <= n; i++)
		while (n % i == 0) {
			n /= i;
			ans++;
		}
	if (n == p)
		return ans + 1;
	return n == 1? ans + 1: ans + 2;
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int numDiv(ll n);

ll const N = 1000 * 1000 * 1000 * 100;
int n;
ll f[4 * 1000 * 10 + 1];

int main() {
	cin >> n;
	ll maxf = N;
	for (int i = 0; i < n; i++) {
		cin >> f[i];
		if (f[i] < maxf)
			maxf = f[i];
	}
	ll minG = N;
	for (int i = 0; i < n; i++) {
		ll gcd = __gcd(f[i], maxf);
		if (gcd < minG)
			minG = gcd;
	}
	cout << numDiv(minG);
	return 0;
}

int numDiv(ll n) {
	if (n == 1)
		return 1;
	ll ans = 1;
	ll p = n;
	for (ll i = 2; i * i <= n; i++)
		while (n % i == 0) {
			n /= i;
			ans++;
		}
	if (n == p)
		return ans + 1;
	return n == 1? ans + 1: ans + 2;
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll numDiv(ll n);

int main() {
	ios::sync_with_stdio(false);
	ll n, k, b;
	cin >> n;
	cin >> k;
	for (int i = 1; i < n; i++) {
		ll a;
		cin >> a;
		k = __gcd(k, a);
	}
	cout << numDiv(k);
	return 0;
}

ll numDiv(ll n) {
	ll ans = 0;
	for (int i = 1; i * i <= n; i++)
		if (n % i == 0)
			i * i == n? ans++: ans += 2;
	return ans;
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll numDiv(ll n);

ll const N = 1000 * 1001;
ll n;
ll f[4 * 1000 * 10 + 1];

int main() {
	cin >> n;
	ll gcd = N * N;
	for (ll i = 0; i < n; i++)
		cin >> f[i];
	gcd = f[0];
	for (ll i = 1; i < n; i++)
		ll gcd = __gcd(f[i], gcd);
	cout << numDiv(gcd);
	return 0;
}

ll numDiv(ll n) {
	if (n == 1)
		return 1;
	ll ans = 1;
	ll p = n;
	for (ll i = 2; i * i <= n; i++)
		while (n % i == 0) {
			n /= i;
			ans++;
		}
	if (n == p)
		return ans + 1;
	return n == 1? ans + 1: ans + 2;
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll numDiv(ll n);

ll n;
ll f[4 * 1000 * 100 + 1];

int main() {
	cin >> n;
	for (ll i = 0; i < n; i++)
		cin >> f[i];
	ll gcd = f[0];
	for (ll i = 1; i < n; i++)
		ll gcd = __gcd(f[i], gcd);
	cout << numDiv(gcd);
	return 0;
}

ll numDiv(ll n) {
	if (n == 1)
		return 1;
	ll ans = 1;
	ll p = n;
	for (ll i = 2; i * i <= n; i++)
		while (n % i == 0) {
			n /= i;
			ans++;
		}
	if (n == p)
		return ans + 1;
	return n == 1? ans + 1: ans + 2;
}


// IN THE NAME OF ALLAH
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll numDiv(ll n);

ll const N = 1000 * 1000 * 1000 * 100;
ll n;
ll f[4 * 1000 * 10 + 1];

int main() {
	cin >> n;
	ll maxf = N * N;
	for (ll i = 0; i < n; i++) {
		cin >> f[i];
		if (f[i] < maxf) {
			maxf = f[i];
		}
	}
	ll minG = N * N;
	for (ll i = 0; i < n; i++) {
		ll gcd = __gcd(f[i], maxf);
		if (gcd < minG)
			minG = gcd;
	}
	cout << numDiv(minG);
	return 0;
}

ll numDiv(ll n) {
	if (n == 1)
		return 1;
	ll ans = 1;
	ll p = n;
	for (ll i = 2; i * i <= n; i++)
		while (n % i == 0) {
			n /= i;
			ans++;
		}
	if (n == p)
		return ans + 1;
	return n == 1? ans + 1: ans + 2;
}


#include <bits/stdc++.h>
#include<iostream>
using namespace std;

long long gcd(long long a,long long b)
{
	if(a==0)
	return b;
	else if(b==0)
	return a;
	else
	return (b,a%b);
}

int main()
{

    		long long n;
    		cin >> n;
    long long arr[n];
    for(int i=0;i<n;i++)
    {
    	cin >> arr[i];
    }
    long long t=arr[0],n1;

    for(long long i=1;i<n;i++)
    {
    		n1=gcd(t,arr[i]);
    		t=n1;

    }

    long long count=0;
    for(long long i=1;i<=sqrt(n1);i++)
    {
    		if(n1%i==0)
    		{
    			if(n1/i==i)
    			{
    				count=count+1;
    			}
    			else
    			{
    				count=count+2;
    			}
    		}

    }

    cout << count << endl;

}


#include <bits/stdc++.h>
#include<iostream>
using namespace std;

long long gcd(long long a,long long b)
{
	if(a==0)
	return b;
	else if(b==0)
	return a;
	else
	return (b,a%b);
}

int main()
{

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

    for(long long i=0;i<n;i++)
    {
    		if(n1!=1)
    		n1=gcd(n1,arr[i]);

    }

    long long count=0;
    for(long long i=1;i*i<=n1;i++)
    {
    		if(n1%i==0)
    		{
    			if(n1/i==i)
    			{
    				count=count+1;
    			}
    			else
    			{
    				count=count+2;
    			}
    		}

    }

    cout << count << endl;

}


#include <bits/stdc++.h>
#include<iostream>
using namespace std;

int gcd(int a,int b)
{
	if(a==0)
	return b;
	else if(b==0)
	return a;
	else
	return (b,a%b);
}

int main()
{

    		int n;
    		cin >> n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
    	cin >> arr[i];
    }
    int t=arr[0],n1;

    for(int i=1;i<n;i++)
    {
    		n1=gcd(t,arr[i]);
    		t=n1;

    }

    int count=0;
    for(int i=1;i<=sqrt(n1);i++)
    {
    		if(n1%i==0)
    		{
    			if(n1/i==i)
    			{
    				count=count+1;
    			}
    			else
    			{
    				count=count+2;
    			}
    		}

    }

    cout << count << endl;

}


    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	long long int n,p,gc=0,c=0,a,i;
    	cin>>n;
    	for(i=0;i<n;i++)
    	{
    		cin>>p;
    		if(gc!=1)
    		gc=__gcd(gc,p);
    	}
    	for(i=1;i*i<=gc;i++)
    	{
    		if(gc%i==0)
    		{
    			if(gc/i==i)
    			c++;
    			else
    			c+=2;
    		}
    	}
    	cout<<c;
    }


#include <bits/stdc++.h>
#include<iostream>
using namespace std;

long long gcd(long long a,long long b)
{
	if(a==0)
	return b;
	else if(b==0)
	return a;
	else
	return (b,a%b);
}

int main()
{

    		long long n;
    		cin >> n;
    long long arr[n];
    for(int i=0;i<n;i++)
    {
    	cin >> arr[i];
    }
    long long t=arr[0],n1=0;

    for(long long i=1;i<n;i++)
    {

    		n1=gcd(n1,arr[i]);

    }

    long long count=0;
    for(long long i=1;i*i<=n1;i++)
    {
    		if(n1%i==0)
    		{
    			if(n1/i==i)
    			{
    				count=count+1;
    			}
    			else
    			{
    				count=count+2;
    			}
    		}

    }

    cout << count << endl;

}


#include <bits/stdc++.h>
#include<iostream>
using namespace std;

int main()
{

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

    for(long long i=0;i<n;i++)
    {
    		if(n1!=1)
    		n1=_gcd(n1,arr[i]);

    }

    long long count=0;
    for(long long i=1;i*i<=n1;i++)
    {
    		if(n1%i==0)
    		{
    			if(n1/i==i)
    			{
    				count=count+1;
    			}
    			else
    			{
    				count=count+2;
    			}
    		}

    }

    cout << count << endl;

}


#include <bits/stdc++.h>
#include<iostream>
using namespace std;

long long gcd(long long a,long long b)
{
	if(a==0)
	return b;
	else if(b==0)
	return a;
	else
	return (b,a%b);
}

int main()
{

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

    for(long long i=0;i<n;i++)
    {
    		n1=gcd(n1,arr[i]);

    }

    long long count=0;
    for(long long i=1;i*i<=n1;i++)
    {
    		if(n1%i==0)
    		{
    			if(n1/i==i)
    			{
    				count=count+1;
    			}
    			else
    			{
    				count=count+2;
    			}
    		}

    }

    cout << count << endl;

}


#include <bits/stdc++.h>
#include<iostream>
using namespace std;

int main()
{

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

    for(long long i=0;i<n;i++)
    {
    		if(n1!=1)
    		n1=__gcd(n1,arr[i]);

    }

    long long count=0;
    for(long long i=1;i*i<=n1;i++)
    {
    		if(n1%i==0)
    		{
    			if(n1/i==i)
    			{
    				count=count+1;
    			}
    			else
    			{
    				count=count+2;
    			}
    		}

    }

    cout << count << endl;

}


#include <bits/stdc++.h>
#include<iostream>
using namespace std;

int gcd(int a,int b)
{
	if(a==0)
	return b;
	else
	return (b,a%b);
}

int main()
{

    		int n;
    		cin >> n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
    	cin >> arr[i];
    }
    int t=arr[0],n1;

    for(int i=1;i<n;i++)
    {
    		n1=gcd(t,arr[i]);
    		t=n1;

    }

    int count=0;
    for(int i=1;i<=sqrt(n1);i++)
    {
    		if(n1%i==0)
    		{
    			if(n1/i==i)
    			{
    				count=count+1;
    			}
    			else
    			{
    				count=count+2;
    			}
    		}

    }

    cout << count << endl;

}


// http://codeforces.com/problemset/problem/1203/C
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define PB push_back
#define ll long long
#define MAX 0x3f3f3f3f3f3f3f3f

// Greatest common divider
ll gcd(ll a, ll b) {
	if(a < b) swap(a, b);
	if(!b) return a;

	for(ll i = 1; i < b; i++) {
		if(a % (b/i) == 0) return b/i;
	}
	return 1;
}

int main() {
	cin.sync_with_stdio(false);

	int n;
	cin>>n;

	ll temp;
	ll gcdNum = 0;
	FOR(i, 0, n) {
		cin>>temp;
		gcdNum = __gcd(gcdNum, temp);
	}

	ll res = 0;

	for(ll i = 1; i <= gcdNum/i; i++) {
		if(gcdNum % i == 0) res += 2;
		if(i*i == gcdNum) res--;
	}

	cout<<res;

	return 0;
}


// http://codeforces.com/problemset/problem/1203/C
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define PB push_back
#define ll long long
#define MAX 0x3f3f3f3f3f3f3f3f

// Greatest common divider
ll gcd(ll a, ll b) {
	if(a < b) swap(a, b);
	if(!b) return a;

	for(ll i = 1; i < b; i++) {
		if(b % i == 0) continue;
		if(a % (b/i) == 0) return b/i;
	}
	return 1;
}

int main() {
	cin.sync_with_stdio(false);

	int n;
	cin>>n;

	ll temp;
	ll gcdNum = 0;
	FOR(i, 0, n) {
		cin>>temp;
		gcdNum = gcd(gcdNum, temp);
	}

	ll res = 0;

	for(ll i = 1; i <= gcdNum/i; i++) {
		if(gcdNum % i == 0) res += 2;
		if(i*i == gcdNum) res--;
	}

	cout<<res;

	return 0;
}


// http://codeforces.com/problemset/problem/1203/C
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define PB push_back
#define ll long long
#define MAX 0x3f3f3f3f3f3f3f3f

int main() {
	int n;
	cin>>n;

	vector<int> arr(n);

	ll temp;
	ll min = MAX;
	FOR(i, 0, n) {
		cin>>temp;
		arr[i] = temp;
		min = min < temp ? min : temp;
	}

	int res = 1;

	for(int i = 2; i <= min; i++) {
		if(min % i == 0) {
			res++;
			for(int j : arr) {
				if(j % i != 0) {
					res--;
					break;
				}
			}
		}
	}

	cout<<res;

	return 0;
}


// http://codeforces.com/problemset/problem/1203/C
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define PB push_back
#define ll long long
#define MAX 0x3f3f3f3f3f3f3f3f

int main() {
	int n;
	cin>>n;

	vector<ll> arr(n);

	ll temp;
	ll min = MAX;
	FOR(i, 0, n) {
		cin>>temp;
		arr[i] = temp;
		min = min < temp ? min : temp;
	}

	ll res = 1;

	for(ll i = 2; i <= min; i++) {
		if(min % i == 0) {
			res++;
			for(ll j : arr) {
				if(j % i != 0) {
					res--;
					break;
				}
			}
		}
	}

	cout<<res;

	return 0;
}


// http://codeforces.com/problemset/problem/1203/C
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define PB push_back
#define ll long long
#define MAX 0x3f3f3f3f3f3f3f3f

int main() {
	cin.sync_with_stdio(false);

	int n;
	cin>>n;

	ll input, temp;
	ll gcdNum = 0;
	FOR(i, 0, n) {
		cin>>input;
		while(input != 0) {
			temp = gcdNum % input;
			gcdNum = input;
			input = temp;
		}
	}

	ll res = 0;

	for(ll i = 1; i <= gcdNum/i; i++) {
		if(gcdNum % i == 0) res += 2;
		if(i*i == gcdNum) res--;
	}

	cout<<res;

	return 0;
}


// http://codeforces.com/problemset/problem/1203/C
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define PB push_back
#define ll long long
#define MAX 0x3f3f3f3f

int main() {
	int n;
	cin>>n;

	vector<int> arr(n);

	ll temp;
	ll min = MAX;
	FOR(i, 0, n) {
		cin>>temp;
		arr[i] = temp;
		min = min < temp ? min : temp;
	}

	int res = 1;

	for(int i = 2; i <= min; i++) {
		if(min % i == 0) {
			res++;
			for(int j : arr) {
				if(j % i != 0) {
					res--;
					break;
				}
			}
		}
	}

	cout<<res;

	return 0;
}


// http://codeforces.com/problemset/problem/1203/C
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define PB push_back
#define ll long long
#define MAX 0x3f3f3f3f3f3f3f3f

int main() {
	cin.sync_with_stdio(false);

	int n;
	cin>>n;

	vector<ll> arr(n);

	ll temp;
	ll min = MAX;
	FOR(i, 0, n) {
		cin>>temp;
		arr[i] = temp;
		min = min < temp ? min : temp;
	}

	unsigned int res = 0;

	vector<ll> numbers(min);
	numbers[res++] = 1;

	for(ll i = 2; i <= min; i++) {
		if(min % i == 0) {
			numbers[res++] = i;
		}
	}

	for(ll i : arr) {
		FOR(j, 0, res) {
			if(i % numbers[j] != 0) {
				numbers.erase(numbers.begin()+j);
				res--;
				break;
			}
		}
	}

	cout<<res;

	return 0;
}


// http://codeforces.com/problemset/problem/1203/C
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define PB push_back
#define ll long long
#define MAX 0x3f3f3f3f3f3f3f3f

// Greatest common dividor
ll gcd(ll a, ll b) {
	if(a < b) swap(a, b);
	if(!b) return a;

	for(ll i = 1; i < b; i++) {
		if(a % (b/i) == 0) return b/i;
	}
	return 1;
}

int main() {
	cin.sync_with_stdio(false);

	int n;
	cin>>n;

	ll temp;
	ll gcdNum = 0;
	FOR(i, 0, n) {
		cin>>temp;
		gcdNum = gcd(gcdNum, temp);
	}

	unsigned int res = 0;

	for(ll i = 1; i <= gcdNum/i; i++) {
		if(gcdNum % i == 0) res += 2;
		if(i*i == gcdNum) res--;
	}

	cout<<res;

	return 0;
}


// http://codeforces.com/problemset/problem/1203/C
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define PB push_back
#define ll long long
#define MAX 0x3f3f3f3f3f3f3f3f

// Greatest common divider
ll gcd(ll a, ll b) {
	if(a < b) swap(a, b);
	if(!b) return a;

	for(ll i = 1; i < b; i++) {
		if(b % i != 0) continue;
		if(a % (b/i) == 0) return b/i;
	}
	return 1;
}

int main() {
	cin.sync_with_stdio(false);

	int n;
	cin>>n;

	ll temp;
	ll gcdNum = 0;
	FOR(i, 0, n) {
		cin>>temp;
		//cout<<gcdNum<<' '<<temp<<" - ";
		gcdNum = gcd(gcdNum, temp);
		//cout<<gcdNum<<'\n';
	}

	ll res = 0;

	for(ll i = 1; i <= gcdNum/i; i++) {
		if(gcdNum % i == 0) res += 2;
		if(i*i == gcdNum) res--;
	}

	cout<<res;

	return 0;
}


// http://codeforces.com/problemset/problem/1203/C
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define PB push_back
#define ll long long
#define MAX 0x3f3f3f3f3f3f3f3f

int main() {
	cin.sync_with_stdio(false);

	int n;
	cin>>n;

	vector<ll> arr(n);

	ll temp;
	ll min = MAX;
	FOR(i, 0, n) {
		cin>>temp;
		arr[i] = temp;
		min = min < temp ? min : temp;
	}

	ll res = 1;

	for(ll i = 2; i <= min; i++) {
		if(min % i == 0) {
			res++;
			for(ll j : arr) {
				if(j % i != 0) {
					res--;
					break;
				}
			}
		}
	}

	cout<<res;

	return 0;
}


// http://codeforces.com/problemset/problem/1203/C
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define PB push_back
#define ll long long
#define MAX 0x3f3f3f3f3f3f3f3f

int main() {
	int n;
	cin>>n;

	vector<int> arr(n);

	ll temp;
	ll min = MAX;
	FOR(i, 0, n) {
		cin>>temp;
		arr[i] = temp;
		min = min < temp ? min : temp;
	}

	ll res = 1;

	for(ll i = 2; i <= min; i++) {
		if(min % i == 0) {
			res++;
			for(ll j : arr) {
				if(j % i != 0) {
					res--;
					break;
				}
			}
		}
	}

	cout<<res;

	return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<stack>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mem(a) memset(a,0,sizeof(a))
#define memm(a) memset(a,inf,sizeof(a))
#define ll long long
#define ld long double
#define uL unsigned long long
#define pb push_back
#define inf 0x3f3f3f3f
using namespace std;
const int N=4e5+5;
const int M=1e6+5;
int n,m,t,w,r[N],l[N];
ll a[N],b[N];
int main()
{
     scanf("%d",&n);
     ll mx=0;
     for(int i=1;i<=n;i++)
     {
        scanf("%I64d",&a[i]);
        mx=max(mx,a[i]);
        int now=sqrt(a[i]);
        for(int j=1;j<=now;j++)
        {
            if(a[i]%j==0)
            {
                b[j]++;
                if(a[i]!=j*j) b[a[i]/j]++;
            }
        }
     }
     while(b[mx]<n) mx--;
     int ans=2;
     if(mx==1) ans=1;
     for(int i=2;i<mx;i++)
     {
         bool f=true;
         for(int j=a[1];j<=a[n];j++)
         {
             if(a[j]%i!=0)
             {
                 f=false;
                 break;
             }
         }
         if(f) ans++;
     }
     printf("%d\n",ans);
}
/*
10
5
2 3 4 5 1
5
3 2 1 5 4
5
4 5 1 2 3
5
1 2 4 5 3
*/


#include<bits/stdc++.h>
#include<iostream>
#include<stack>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mem(a) memset(a,0,sizeof(a))
#define memm(a) memset(a,inf,sizeof(a))
#define ll long long
#define ld long double
#define uL unsigned long long
#define pb push_back
#define inf 0x3f3f3f3f
using namespace std;
const int N=4e5+5;
const int M=1e4+5;
int n,m,t,w,vis[N],l[N];
ll a[N];
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
     cin>>n;
     ll sum=0;
     for(ll i=1;i<=n;i++)
        cin>>a[i];
     if(n==1)
     {
         for(ll i=1;i*i<=a[1];i++)
         {
             if(a[1]%i==0)
             {
                 sum++;
                 if(i!=a[1]/i) sum++;
             }
         }
         cout<<sum<<endl;
         return 0;
     }
     ll now=gcd(a[1],a[2]);
     for(ll i=3;i<=n;i++)
        now=gcd(now,a[i]);
     for(ll i=1;i*i<=now;i++)
     {
         if(now%i==0)
         {
            sum++;
            if(i!=now/i) sum++;
         }
     }
     cout<<sum<<endl;
     return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<stack>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mem(a) memset(a,0,sizeof(a))
#define memm(a) memset(a,inf,sizeof(a))
#define ll long long
#define ld long double
#define uL unsigned long long
#define pb push_back
#define inf 0x3f3f3f3f
using namespace std;
const int N=4e5+5;
const int M=1e6+5;
int n,m,t,w,r[N],l[N];
ll a[N],b[N];
int main()
{
     scanf("%d",&n);
     ll mx=0;
     for(int i=1;i<=n;i++)
     {
        scanf("%I64d",&a[i]);
        mx=max(mx,a[i]);
        int now=sqrt(a[i]);
        for(int j=1;j<=now;j++)
        {
            if(a[i]%j==0)
            {
                b[j]++;
                if(a[i]!=j*j) b[a[i]/j]++;
            }
        }
     }
     int ans=0;
     for(int i=1;i<=n;i++)
      if(b[i]==n) ans++;
     printf("%d\n", ans);
}
/*
10
5
2 3 4 5 1
5
3 2 1 5 4
5
4 5 1 2 3
5
1 2 4 5 3
*/


#include<bits/stdc++.h>
#include<iostream>
#include<stack>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mem(a) memset(a,0,sizeof(a))
#define memm(a) memset(a,inf,sizeof(a))
#define ll long long
#define ld long double
#define uL unsigned long long
#define pb push_back
#define inf 0x3f3f3f3f
using namespace std;
const int N=1e7+5;
const int M=1e6+5;
int n,m,t,w,r[N],l[N];
ll a[N],b[N];
int main()
{
     scanf("%d",&n);
     ll mx=0;
     for(int i=1;i<=n;i++)
     {
        scanf("%I64d",&a[i]);
        mx=max(mx,a[i]);
        int now=sqrt(a[i]);
        for(int j=1;j<=now;j++)
        {
            if(a[i]%j==0)
            {
                b[j]++;
                if(a[i]!=j*j) b[a[i]/j]++;
            }
        }
     }
     int ans=0;
     for(int i=1;i<=sqrt(1e12);i++)
      if(b[i]==n) ans++;
     printf("%d\n", ans);
}
/*
10
5
2 3 4 5 1
5
3 2 1 5 4
5
4 5 1 2 3
5
1 2 4 5 3
*/


#include<bits/stdc++.h>
#include<iostream>
#include<stack>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mem(a) memset(a,0,sizeof(a))
#define memm(a) memset(a,inf,sizeof(a))
#define ll long long
#define ld long double
#define uL unsigned long long
#define pb push_back
#define inf 0x3f3f3f3f
using namespace std;
const int N=4e5+5;
const int M=1e4+5;
int n,m,t,w,vis[N],l[N];
ll a[N];
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
     cin>>n;
     ll sum=0;
     for(int i=1;i<=n;i++)
        cin>>a[i];
     if(n==1)
     {
         for(int i=1;i*i<=a[1];i++)
         {
             if(a[i]%i==0)
             {
                 sum++;
                 if(i*i!=a[i]) sum++;
             }
         }
         cout<<sum<<endl;
         return 0;
     }
     ll now=gcd(a[1],a[2]);
     for(int i=3;i<=n;i++)
        now=gcd(now,a[i]);
     for(ll i=1;i*i<=now;i++)
     {
         if(now%i==0)
         {
            sum++;
            if(i*i!=now) sum++;
         }
     }
     cout<<sum<<endl;
     return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<stack>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mem(a) memset(a,0,sizeof(a))
#define memm(a) memset(a,inf,sizeof(a))
#define ll long long
#define ld long double
#define uL unsigned long long
#define pb push_back
#define inf 0x3f3f3f3f
using namespace std;
const int N=4e5+5;
const int M=1e9+7;
int n,m,w,vis[N];
ll a[N],b[N];
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
   fio;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
       cin>>a[i];
   }
   ll sum=0,t;
   if(n==1)
   {
     t=a[1];
     for(int i=1;i*i<=t;i++)
     {
         if(t%i==0)
         {
             sum++;
             if(i*i!=t) sum++;
         }
     }
     cout<<sum<<endl;
     return 0;
   }
   t=gcd(a[1],a[2]);
   for(int i=3;i<=n;i++)
   {
       t=gcd(t,a[i]);
   }
   for(int i=1;i*i<=t;i++)
   {
       if(t%i==0)
         {
             sum++;
             if(i*i!=t) sum++;
         }
   }
   cout<<sum<<endl;
   return 0;
}
/*
b
*/


#include<bits/stdc++.h>
#include<iostream>
#include<stack>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mem(a) memset(a,0,sizeof(a))
#define memm(a) memset(a,inf,sizeof(a))
#define ll long long
#define ld long double
#define uL unsigned long long
#define pb push_back
#define inf 0x3f3f3f3f
using namespace std;
const int N=4e5+5;
const int M=1e4+5;
int n,m,t,w,vis[N],l[N];
ll a[N];
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
     cin>>n;
     ll sum=0;
     for(ll i=1;i<=n;i++)
        cin>>a[i];
     if(n==1)
     {
         for(ll i=1;i*i<=a[1];i++)
         {
             if(a[i]%i==0)
             {
                 sum++;
                 if(i!=a[i]/i) sum++;
             }
         }
         cout<<sum<<endl;
         return 0;
     }
     ll now=gcd(a[1],a[2]);
     for(ll i=3;i<=n;i++)
        now=gcd(now,a[i]);
     for(ll i=1;i*i<=now;i++)
     {
         if(now%i==0)
         {
            sum++;
            if(i!=now/i) sum++;
         }
     }
     cout<<sum<<endl;
     return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<stack>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mem(a) memset(a,0,sizeof(a))
#define memm(a) memset(a,inf,sizeof(a))
#define ll long long
#define ld long double
#define uL unsigned long long
#define pb push_back
#define inf 0x3f3f3f3f
using namespace std;
const int N=4e5+5;
const int M=1e9+7;
int n,m,w,vis[N];
ll a[N],b[N];
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
   fio;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
       cin>>a[i];
   }
   ll sum=0,t;
   if(n==1)
   {
     t=a[1];
     for(ll i=1;i*i<=t;i++)
     {
         if(t%i==0)
         {
             sum++;
             if(i*i!=t) sum++;
         }
     }
     cout<<sum<<endl;
     return 0;
   }
   t=gcd(a[1],a[2]);
   for(int i=3;i<=n;i++)
   {
       t=gcd(t,a[i]);
   }
   for(ll i=1;i*i<=t;i++)
   {
       if(t%i==0)
         {
             sum++;
             if(i*i!=t) sum++;
         }
   }
   cout<<sum<<endl;
   return 0;
}
/*
b
*/


#include<bits/stdc++.h>
#include<iostream>
#include<stack>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mem(a) memset(a,0,sizeof(a))
#define memm(a) memset(a,inf,sizeof(a))
#define ll long long
#define ld long double
#define uL unsigned long long
#define pb push_back
#define inf 0x3f3f3f3f
using namespace std;
const int N=4e5+5;
const int M=1e4+5;
int n,m,t,w,vis[N],l[N];
ll a[N];
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
     cin>>n;
     ll sum=0;
     for(ll i=1;i<=n;i++)
        cin>>a[i];
     if(n==1)
     {
         for(ll i=1;i*i<=a[1];i++)
         {
             if(a[i]%i==0)
             {
                 sum++;
                 if(i*i!=a[i]) sum++;
             }
         }
         cout<<sum<<endl;
         return 0;
     }
     ll now=gcd(a[1],a[2]);
     for(ll i=3;i<=n;i++)
        now=gcd(now,a[i]);
     for(ll i=1;i*i<=now;i++)
     {
         if(now%i==0)
         {
            sum++;
            if(i*i!=now) sum++;
         }
     }
     cout<<sum<<endl;
     return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<stack>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mem(a) memset(a,0,sizeof(a))
#define memm(a) memset(a,inf,sizeof(a))
#define ll long long
#define ld long double
#define uL unsigned long long
#define pb push_back
#define inf 0x3f3f3f3f
using namespace std;
const int N=1e7+5;
const int M=1e6+5;
int n,m,t,w,r[N],l[N];
ll a[N],b[N];
int main()
{
     scanf("%d",&n);
     ll mx=0;
     for(int i=1;i<=n;i++)
     {
        scanf("%I64d",&a[i]);
        mx=max(mx,a[i]);
        int now=sqrt(a[i]);
        for(int j=1;j<=now;j++)
        {
            if(a[i]%j==0)
            {
                b[j]++;
                if(a[i]!=j*j) b[a[i]/j]++;
            }
        }
     }
     int ans=0;
     for(int i=1;i<=n;i++)
      if(b[i]==n) ans++;
     printf("%d\n", ans);
}
/*
10
5
2 3 4 5 1
5
3 2 1 5 4
5
4 5 1 2 3
5
1 2 4 5 3
*/


    #include<bits/stdc++.h>
    using namespace std;
    #define forn(i,l,u) for(i=l;i<u;i++)
    int gcd(long long a,long long b){
        if(b == 0)
            return a;
        if(a>b)
            return gcd(b,a%b);
        else
            return gcd(a,b%a);

    }
    int main(){
        //ios_base::sync_with_stdio(false);
        //cin.tie(NULL);
        //int t;
        //cin>>t;
        int n,i;
        cin>>n;
        long long a[n];

        forn(i,0,n){
            cin>>a[i];
        }
        //sort(a,a+n);
        long long cnt = 1;
        long long x = a[0];
        forn(i,1,n-1){
            x = gcd(x,a[i]);
        }
        if(x != 1){
            cnt++;
        }
        for(long long i = 2;i<=round(sqrt(x));i++){
            if(x%i == 0){
                cnt += 2;
            }
        }
        cout<<cnt<<"\n";
    }


    #include<bits/stdc++.h>
    using namespace std;
    #define forn(i,l,u) for(i=l;i<u;i++)
    int gcd(long long a,long long b){
        if(b == 0)
            return a;
        if(a>b)
            return gcd(b,a%b);
        else
            return gcd(a,b%a);

    }
    int main(){
        //ios_base::sync_with_stdio(false);
        //cin.tie(NULL);
        //int t;
        //cin>>t;
        int n,i;
        cin>>n;
        long long a[n];

        forn(i,0,n){
            cin>>a[i];
        }
        //sort(a,a+n);
        long long cnt = 1;
        long long x = a[0];
        forn(i,1,n){
            x = gcd(x,a[i]);
        }
        if(x != 1){
            cnt++;
        }
        for(long long i = 2;i<=round(sqrt(x));i++){
            if(x%i == 0){
                cnt += 2;
            }
        }
        cout<<cnt<<"\n";
    }


    #include<bits/stdc++.h>
    using namespace std;
    #define forn(i,l,u) for(i=l;i<u;i++)
    long long gcd(long long a,long long b){
        if (!a)
            return b;
    return gcd(b%a,a);

    }
    int main(){
        //ios_base::sync_with_stdio(false);
        //cin.tie(NULL);
        //int t;
        //cin>>t;
        int n,i;
        cin>>n;
        long long a[n];
        long long x = 0;
        forn(i,0,n){
            cin>>a[i];
            x = gcd(x,a[i]);
        }
        //sort(a,a+n);
        long long cnt = 1;
        if(x != 1){
            cnt++;
        }
        for(long long i = 2;i*i <= x; i++){
            if(x%i == 0){
                cnt++;
                if(i != x/i){
                    cnt++;
                }

            }
        }
        cout<<cnt<<"\n";
    }


    #include<bits/stdc++.h>
    using namespace std;
    #define forn(i,l,u) for(i=l;i<u;i++)
    int main(){
        //ios_base::sync_with_stdio(false);
        //cin.tie(NULL);
        //int t;
        //cin>>t;
        int n,i;
        cin>>n;
        long long a[n];

        forn(i,0,n){
            cin>>a[i];
        }
        sort(a,a+n);
        int cnt = 1;
        for(long long i = 2;i<=a[0];i++){
            int flag = 0;
            for(int j = 0;j<n;j++){
                if(a[j]%i != 0){
                    flag = 1;
                    break;
                }
            }
            if(flag == 0){
                cnt++;
            }

        }
        cout<<cnt<<"\n";
    }


    #include<bits/stdc++.h>
    using namespace std;
    #define forn(i,l,u) for(i=l;i<u;i++)
    int gcd(long long a,long long b){
        if (!a)
            return b;
    return gcd(b%a,a);

    }
    int main(){
        //ios_base::sync_with_stdio(false);
        //cin.tie(NULL);
        //int t;
        //cin>>t;
        int n,i;
        cin>>n;
        long long a[n];
        long long x = 0;
        forn(i,0,n){
            cin>>a[i];
            x = gcd(x,a[i]);
        }
        //sort(a,a+n);
        long long cnt = 1;
        if(x != 1){
            cnt++;
        }
        for(long long i = 2;i*i <= x; i++){
            if(x%i == 0){
                cnt++;
                if(i != x/i){
                    cnt++;
                }

            }
        }
        cout<<cnt<<"\n";
    }


    #include<bits/stdc++.h>
    using namespace std;
    #define forn(i,l,u) for(i=l;i<u;i++)
    int main(){
        //ios_base::sync_with_stdio(false);
        //cin.tie(NULL);
        //int t;
        //cin>>t;
        int n,i;
        cin>>n;
        int a[n];

        forn(i,0,n){
            cin>>a[i];
        }
        sort(a,a+n);
        int cnt = 1;
        for(int i = 2;i<=a[0];i++){
            int flag = 0;
            for(int j = 0;j<n;j++){
                if(a[j]%i != 0){
                    flag = 1;
                    break;
                }
            }
            if(flag == 0){
                cnt++;
            }

        }
        cout<<cnt<<"\n";
    }


    #include<bits/stdc++.h>
    using namespace std;
    #define forn(i,l,u) for(i=l;i<u;i++)
    int main(){
        //ios_base::sync_with_stdio(false);
        //cin.tie(NULL);
        //int t;
        //cin>>t;
        int n,i;
        cin>>n;
        long long a[n];

        forn(i,0,n){
            cin>>a[i];
        }
        //sort(a,a+n);
        int cnt = 1;
        vector<int> res;
        if(a[0] != 1)
            res.push_back(a[0]);
        for(int i =2;i<=round(sqrt(a[0]));i++){
            if(a[0]%i == 0){
                res.push_back(i);
                res.push_back(a[0]/i);
            }
        }
        for(int j = 0;j<res.size();j++){
            int flag = 0;
            for(int i= 1;i<n;i++){
                if(a[i]%res[j] != 0){
                    flag = 1;
                    break;
                }
            }
            if(flag == 0){
                cnt++;
            }
        }
        cout<<cnt<<"\n";
    }


import static java.lang.Math.* ;
import static java.util.Arrays.* ;

import java.math.BigInteger;
import java.util.*;
import java.io.*;

public class Main
{

    void main() throws Exception
    {
        Scanner sc = new Scanner(System.in) ;
        PrintWriter out = new PrintWriter(System.out) ;
        int TC = sc.nextInt() ;
        while(TC-->0) {
            char[] s = sc.next().toCharArray();
            SuffixAutomaton sa = new SuffixAutomaton(s);
            long ans = 0 ;
            for(int v = 1 ; v <= sa.idx ; v++)
                ans += (1L * sa.cnt[v] * sa.cnt[v]) * (sa.len[v] - sa.len[sa.link[v]]) ;
            out.println(ans);
        }
        out.flush();
        out.close();
    }
    class SuffixAutomaton
    {
        int[] link, len , cnt;
        int [][] next ;
        boolean [] isClone ;
        int lst, idx;
        int [] endPos ;

        SuffixAutomaton(char[] s)
        {
            int n = s.length;
            link = new int[n<<1];
            len = new int[n<<1];
            next = new int [26][n << 1] ;
            cnt = new int [n << 1] ;
            endPos = new int [n << 1] ;
            isClone = new boolean[n << 1] ;
            int ix = 0 ;
            for(char c: s)
                addLetter(c - 'a' , ix ++);

            Integer [] id = new Integer[idx + 1] ;

            for(int i = 0 ; i <= idx ; i++) {
                id[i] = i;
                isClone[i] = cnt[i] == 0;
            }

            sort(id , (x , y)->len[y] - len[x]);

            for(int v : id)
                cnt[link[v]] += cnt[v] ;
        }

        void addLetter(int c , int ix)
        {
            int cur = ++idx, p = lst;
            endPos[cur] = ix ;
            while(next[c][p] == 0) { next[c][p] = cur; p = link[p]; }
            cnt[cur] = 1 ;
            int q = next[c][p];
            if(q != cur)
                if(len[q] == len[p] + 1)
                    link[cur] = q;
                else
                {
                    int clone = ++idx;
                    len[clone] = len[p] + 1;
                    link[clone] = link[q];
                    endPos[clone] = endPos[q] ;
                    for(int i = 0 ; i < 26 ; i++)
                        next[i][clone] = next[i][q] ;
                    link[cur] = link[q] = clone;
                    while(next[c][p] == q) { next[c][p] =  clone; p = link[p]; }
                }
            len[cur] = len[lst] + 1;
            lst = cur;
        }
    }

    class Scanner
    {
        BufferedReader br;
        StringTokenizer st;

        Scanner(InputStream in)
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        Scanner(String path) throws Exception
        {
            br = new BufferedReader(new FileReader(path)) ;
        }
        String next() throws Exception
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        int nextInt() throws Exception { return Integer.parseInt(next()); }

        long nextLong() throws Exception { return Long.parseLong(next()); }

        double nextDouble() throws Exception { return Double.parseDouble(next());}
    }

    public static void main (String [] args) throws Exception {(new Main()).main();}

}


import java.math.BigInteger;
import java.util.*;
import java.io.*;

public class Main {

    public static InputReader in = new InputReader(System.in);
    public static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args)
    {
        int a;
        String s;
        SAM part=new SAM();
        a=in.nextInt();
        while (a--!=0)
        {
            s=in.next();
            part.init(2*s.length()+2,26);
            for(int i=0;i<s.length();++i)
                part.insert(s.charAt(i)-'a');
            long ans=0;
            part.topo();
            SAM_node part2=part.root;
            for(int i=0;i<s.length();++i)
            {
                part2=part2.next[s.charAt(i)-'a'];
                part2.cnt=1;
            }
            for(int i=part.cur-1;i>0;--i)
                part.pool[i].pre.cnt+=part.pool[i].cnt;
            for(int i=part.cur-1;i>0;--i)
                ans+=(long)part.pool[i].cnt*(long)part.pool[i].cnt*((long)part.pool[i].step-(long)part.pool[i].pre.step);
            out.println(ans);
        }
        out.flush();
        out.close();
    }
}
class SAM_node
{
    SAM_node pre,next[];
    int step,cnt;
    SAM_node(int sigma)
    {
        next=new SAM_node[sigma];
        Arrays.fill(next,null);
        step=0;
        cnt=0;
        pre=null;
    }
}
class SAM
{
    SAM_node SAM_pool[],root,last;
    int d[];
    SAM_node pool[];
    int cur;
    int sigma;
    void topo() {
        int cnt = cur;
        int maxVal = 0;
        Arrays.fill(d, 0);
        for (int i = 1; i < cnt; i++) {
            maxVal = Math.max(maxVal, SAM_pool[i].step);

        d[SAM_pool[i].step]++;
    }
        for (int i = 1; i <= maxVal; i++)
            d[i] += d[i - 1];
        for (int i = 1; i < cnt; i++)
            pool[d[SAM_pool[i].step]--] = SAM_pool[i];
        pool[0] = root;
    }
    void init(int a,int b)
    {
        d=new int[a];
        pool=new SAM_node[a];
        SAM_pool=new SAM_node[a];
        SAM_pool[0]=new SAM_node(b);
        sigma=b;
        root=last=SAM_pool[0];
        cur=1;
    }
    void insert(int w)
    {
        SAM_node p=last;
        SAM_pool[cur]=new SAM_node(sigma);
        SAM_node np=SAM_pool[cur];
        last=np;
        cur++;
        np.step=p.step+1;
        while (p!=null && p.next[w]==null)
        {
            p.next[w]=np;
            p = p.pre;
        }
        if(p==null)
        {
            np.pre=root;
        }
        else
        {
            SAM_node q=p.next[w];
            if(p.step+1==q.step)
                np.pre=q;
            else {
                SAM_node nq = SAM_pool[cur++] = new SAM_node(sigma);
                nq.next = Arrays.copyOf(q.next, sigma);
                nq.cnt = q.cnt;
                nq.step = p.step + 1;
                nq.pre = q.pre;
                q.pre = nq;
                np.pre = nq;
                while (p != null && p.next[w]==(q)) {
                    p.next[w] = nq;
                    p = p.pre;
                }
            }
        }
    }
}
class InputReader{
    private final static int BUF_SZ = 65536;
    BufferedReader in;
    StringTokenizer tokenizer;
    public InputReader(InputStream in) {
        super();
        this.in = new BufferedReader(new InputStreamReader(in),BUF_SZ);
        tokenizer = new StringTokenizer("");
    }
    public String next() {
        while (!tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong()
    {
        return Long.parseLong(next());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public class SumOfSquares {
    public static void main(String[] args) throws IOException {
        in.nextToken();
        int tests = (int) in.nval;

        for (int T = 0; T < tests; T++) {
            LrsArray lrsArray = new LrsArray();

            Map<Integer, List<Integer>> repeats = new HashMap<>();

            in.nextToken();
            for (char c : in.sval.toCharArray()) {
                LrsArray.Lmo repeat = lrsArray.append(c);
                if (repeat.length > 0) {
                    addValue(repeats, repeat.rightEnd, lrsArray.text.size() - 1);
                } else {
                    addValue(repeats, 0, lrsArray.text.size() - 1);
                }
            }

            HashMap<Integer, Long> counts = new HashMap<>();
            dfs(repeats, counts, 0);

            long sumOfSquares = 0;
            for (int i = 1; i < lrsArray.text.size(); i++) {
                LrsArray.Lmo lmo = lrsArray.lrs.get(i);

                sumOfSquares += i - lmo.length;

                if (lmo.length > 0 && counts.containsKey(lmo.rightEnd)) {
                    long length = lmo.length - lmo.lrs().length;
                    sumOfSquares += length * square(counts.get(lmo.rightEnd)) - length;
                    counts.remove(lmo.rightEnd);
                }
            }

            out.println(sumOfSquares);
        }

        out.flush();
    }

    static long square(long x) {
        return x * x;
    }

    static long dfs(Map<Integer, List<Integer>> tree, Map<Integer, Long> counts, Integer node) {
        long result = 1;

        for (Integer child : tree.getOrDefault(node, Collections.emptyList())) {
            result += dfs(tree, counts, child);
        }

        counts.put(node, result);

        return result;
    }

    static <K, V> void addValue(Map<K, List<V>> map, K key, V value) {
        if (!map.containsKey(key)) {
            map.put(key, new ArrayList<>());
        }
        map.get(key).add(value);
    }

    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(
            System.in, StandardCharsets.ISO_8859_1
    )));

    static PrintWriter out = new PrintWriter(new OutputStreamWriter(
            System.out, StandardCharsets.ISO_8859_1
    ));
}

class LrsArray {
    List<Character> text = arrayList(null);

    Map<Pair<Lmo, Character>, Integer> extensions = new HashMap<>();

    List<Lmo> lrs = arrayList(new Lmo(-1, -1) {
        @Override
        boolean isNext(char c) {
            return true;
        }
    });

    Lmo append(char c) {
        text.add(c);

        Lmo longest = lrs.get(lrs.size() - 1);

        while (!longest.hasExtension(c)) {
            extensions.put(Pair.of(longest, c), lrs.size());
            longest = longest.lps();
        }

        longest = longest.extend(c);
        lrs.add(longest);

        return longest;
    }

    class Lmo {
        final int rightEnd;
        final int length;

        Lmo(int rightEnd, int length) {
            this.rightEnd = rightEnd;
            this.length = length;
        }

        boolean isNext(char c) {
            return text.get(rightEnd + 1) == c;
        }

        boolean hasExtension(char c) {
            return isNext(c) || extensions.containsKey(Pair.of(this, c));
        }

        Lmo extend(char c) {
            return new Lmo(
                    isNext(c)
                            ? rightEnd + 1
                            : extensions.get(Pair.of(this, c)),
                    length + 1
            );
        }

        Lmo lrs() {
            return lrs.get(rightEnd);
        }

        Lmo lps() {
            return length - 1 == lrs().length
                    ? lrs()
                    : new Lmo(rightEnd, length - 1);
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Lmo lmo = (Lmo) o;
            return rightEnd == lmo.rightEnd &&
                    length == lmo.length;
        }

        @Override
        public int hashCode() {
            return Objects.hash(rightEnd, length);
        }
    }

    static <T> List<T> arrayList(T single) {
        ArrayList<T> arrayList = new ArrayList<>(1);
        arrayList.add(single);
        return arrayList;
    }
}

class Pair<T1, T2> {
    final T1 p1;
    final T2 p2;

    Pair(T1 p1, T2 p2) {
        this.p1 = p1;
        this.p2 = p2;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair<?, ?> pair = (Pair<?, ?>) o;
        return Objects.equals(p1, pair.p1) &&
                Objects.equals(p2, pair.p2);
    }

    @Override
    public int hashCode() {
        return Objects.hash(p1, p2);
    }

    static <T1, T2> Pair<T1, T2> of(T1 p1, T2 p2) {
        return new Pair<>(p1, p2);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;

public class SumOfSquares {
    public static void main(String[] args) throws IOException {
        in.nextToken();
        int tests = (int) in.nval;

        for (int T = 0; T < tests; T++) {
            LrsArray lrsArray = new LrsArray();

            Map<Integer, List<Integer>> repeats = new HashMap<>();

            in.nextToken();
            for (char c : in.sval.toCharArray()) {
                LrsArray.Lmo repeat = lrsArray.append(c);
                if (repeat.length > 0) {
                    addValue(repeats, repeat.rightEnd, lrsArray.text.size() - 1);
                } else {
                    addValue(repeats, 0, lrsArray.text.size() - 1);
                }
            }

            TreeMap<LrsArray.Lmo, Long> counts = new TreeMap<>();
            dfs(repeats, lrsArray.lrs, counts, 0);

            long sumOfSquares = 0;
            for (int i = 1; i < lrsArray.text.size(); i++) {
                LrsArray.Lmo lmo = lrsArray.lrs.get(i);

                sumOfSquares += i - lmo.length;
            }

            int lastEnd = 0;
            int lastLen = 0;
            for (Map.Entry<LrsArray.Lmo, Long> entry : counts.entrySet()) {
                LrsArray.Lmo lmo = entry.getKey();

                if (lastEnd != lmo.rightEnd) {
                    lastEnd = lmo.rightEnd;
                    lastLen = lmo.lrs().length;
                }

                long length = lmo.length - lastLen;
                sumOfSquares += length * square(entry.getValue() + 1) - length;

                lastLen = lmo.length;
            }

            out.println(sumOfSquares);
        }

        out.flush();
    }

    static long square(long x) {
        return x * x;
    }

    static long dfs(Map<Integer, List<Integer>> tree, List<LrsArray.Lmo> lrs, Map<LrsArray.Lmo, Long> counts, Integer node) {
        long result = 1;

        TreeMap<Integer, Long> sorted = new TreeMap<>();
        Map<Integer, LrsArray.Lmo> lmos = new HashMap<>();

        for (Integer child : tree.getOrDefault(node, Collections.emptyList())) {
            long value = dfs(tree, lrs, counts, child);

            sorted.merge(lrs.get(child).length, value, (x, y) -> x + y);
            lmos.put(lrs.get(child).length, lrs.get(child));
            result += value;
        }

        long count = 0;
        for (Map.Entry<Integer, Long> entry : sorted.descendingMap().entrySet()) {
            count += entry.getValue();
            counts.put(lmos.get(entry.getKey()), count);
        }

        return result;
    }

    static <K, V> void addValue(Map<K, List<V>> map, K key, V value) {
        if (!map.containsKey(key)) {
            map.put(key, new ArrayList<>());
        }
        map.get(key).add(value);
    }

    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(
            System.in, StandardCharsets.ISO_8859_1
    )));

    static PrintWriter out = new PrintWriter(new OutputStreamWriter(
            System.out, StandardCharsets.ISO_8859_1
    ));
}

class LrsArray {
    List<Character> text = arrayList(null);

    Map<Pair<Lmo, Character>, Integer> extensions = new HashMap<>();

    List<Lmo> lrs = arrayList(new Lmo(-1, -1) {
        @Override
        boolean isNext(char c) {
            return true;
        }
    });

    Lmo append(char c) {
        text.add(c);

        Lmo longest = lrs.get(lrs.size() - 1);

        while (!longest.hasExtension(c)) {
            extensions.put(Pair.of(longest, c), lrs.size());
            longest = longest.lps();
        }

        longest = longest.extend(c);
        lrs.add(longest);

        return longest;
    }

    class Lmo implements Comparable<Lmo> {
        final int rightEnd;
        final int length;

        Lmo(int rightEnd, int length) {
            this.rightEnd = rightEnd;
            this.length = length;
        }

        boolean isNext(char c) {
            return text.get(rightEnd + 1) == c;
        }

        boolean hasExtension(char c) {
            return isNext(c) || extensions.containsKey(Pair.of(this, c));
        }

        Lmo extend(char c) {
            return new Lmo(
                    isNext(c)
                            ? rightEnd + 1
                            : extensions.get(Pair.of(this, c)),
                    length + 1
            );
        }

        Lmo lrs() {
            return lrs.get(rightEnd);
        }

        Lmo lps() {
            return length - 1 == lrs().length
                    ? lrs()
                    : new Lmo(rightEnd, length - 1);
        }

        @Override
        public int compareTo(LrsArray.Lmo o) {
            if (rightEnd == o.rightEnd) {
                return Integer.compare(length, o.length);
            } else {
                return Integer.compare(rightEnd, o.rightEnd);
            }
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Lmo lmo = (Lmo) o;
            return rightEnd == lmo.rightEnd &&
                    length == lmo.length;
        }

        @Override
        public int hashCode() {
            return Objects.hash(rightEnd, length);
        }

        @Override
        public String toString() {
            return rightEnd + " " + length;
        }
    }

    static <T> List<T> arrayList(T single) {
        ArrayList<T> arrayList = new ArrayList<>(1);
        arrayList.add(single);
        return arrayList;
    }
}

class Pair<T1, T2> {
    final T1 p1;
    final T2 p2;

    Pair(T1 p1, T2 p2) {
        this.p1 = p1;
        this.p2 = p2;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair<?, ?> pair = (Pair<?, ?>) o;
        return Objects.equals(p1, pair.p1) &&
                Objects.equals(p2, pair.p2);
    }

    @Override
    public int hashCode() {
        return Objects.hash(p1, p2);
    }

    static <T1, T2> Pair<T1, T2> of(T1 p1, T2 p2) {
        return new Pair<>(p1, p2);
    }
}


import java.util.*;
import java.math.*;
import java.io.*;

public class CF802I {
	final int ALPHA = 26;
	final int OFFSET = 'a';
	int next, MAX, last, len[], link[], trie[][];
	long[] dp;
	boolean[] terminal;
	void suffixAutomaton(char[] s) {
		MAX = s.length << 1;
		next = 1;  last = 0;
		len = new int[MAX];
		link = new int[MAX];
		trie = new int[ALPHA][MAX];
		terminal = new boolean[MAX];
		link[0] = -1;
		for(char cc : s) {
			int c = cc - OFFSET;
			int cur = next++;
			len[cur] = len[last] + 1;
			int p = last;
			while(p != -1 && trie[c][p] == 0) {
				trie[c][p] = cur;
				p = link[p];
			}
			if(p == -1) {
				link[cur] = 0;
			} else {
				int q = trie[c][p];
				if(len[p] + 1 == len[q]) {
					link[cur] = q;
				} else {
					int clone = next++;
					len[clone] = len[p] + 1;
					link[clone] = link[q];
					for(int i = 0 ; i < ALPHA ; i++)
						trie[i][clone] = trie[i][q];
					while(p != -1 && trie[c][p] == q) {
						trie[c][p] = clone;
						p = link[p];
					}
					link[q] = link[cur] = clone;
				}
			}
			last = cur;
		}
		terminal = new boolean[MAX];
		int p = last;
		while(p > 0) {
			terminal[p] = true;
			p = link[p];
		}
		dp = new long[MAX];
		dfs(0);
	}
	void dfs(int node) {
		if(dp[node] != 0) return;
		dp[node] = terminal[node] ? 1 : 0;
		for(int let = 0 ; let < ALPHA ; let++) {
			if(trie[let][node] != 0) {
				dfs(trie[let][node]);
				dp[node] += dp[trie[let][node]];
			}
		}
	}
	public CF802I() {
		FS scan = new FS();
		PrintWriter out = new PrintWriter(System.out);
		int t = scan.nextInt();
		for(int tt = 0 ; tt < t ; tt++) {
			char[] s = scan.next().toCharArray();
			suffixAutomaton(s);
			long res = 0;
			for(int node = 1 ; node < MAX ; node++)
				res += dp[node] * dp[node] * (len[node] - len[link[node]]);
			out.println(res);
		}
		out.close();
	}
	class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() {
			while(!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch(Exception e) { e.printStackTrace(); }
			}
			return st.nextToken();
		}
		public int nextInt() { return Integer.parseInt(next()); }
	}
	public static void main(String[] args) { new CF802I(); }
}


//Created by Aminul on 9/3/2019.

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

import static java.lang.Math.max;

public class CF802I {
    public static void main(String[] args) throws Exception {
        //Scanner in = new Scanner(System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int test = Integer.parseInt(br.readLine());
        for(int t = 1; t <= test; t++) {
            char[] s = br.readLine().toCharArray();
            int n = s.length;
            int sa[] = suffixArray(s);
            final int lcp[] = lcp(sa, s);
            long ans = 0;

            SegTree segTree = new SegTree(n + 1);
            for (int i = n - 1; i >= 0; i--) {
                int len = n - sa[i];
                ans += segTree.query(1, len) + len;
                segTree.clearRange(lcp[i] + 1, n);
                segTree.update(1, lcp[i], 1);
            }

            segTree = new SegTree(n + 1);
            for (int i = 0; i < n; i++) {
                int len = n - sa[i];
                ans += segTree.query(1, len);
                if(i + 1 < n) segTree.clearRange(lcp[i + 1] + 1, n);
                if(i + 1 < n) segTree.update(1, lcp[i + 1], 1);
            }

            pw.println(ans);
        }
        pw.close();
    }

    static int[] suffixArray(char[] S) {
        int n = S.length;
        Integer ord[] = new Integer[n];
        for (int i = 0; i < n; i++) ord[i] = n - 1 - i;
        Arrays.sort(ord, (a, b) -> Character.compare(S[a], S[b]));
        int order[] = new int[n];
        for (int i = 0; i < n; i++) order[i] = ord[i];
        //Arrays.sort(order, new Comparator<Integer>() {public int compare(Integer o1, Integer o2) { return S[o1] - S[o2]; }});
        int[] sa = new int[n];
        int[] classes = new int[n];
        for (int i = 0; i < n; i++) {
            sa[i] = order[i];
            classes[i] = S[i];
        }
        for (int len = 1; len < n; len <<= 1) {
            //int[] c = classes.clone();
            int c[] = Arrays.copyOf(classes, n);
            for (int i = 0; i < n; i++) {
                classes[sa[i]] = i > 0 && c[sa[i - 1]] == c[sa[i]] && sa[i - 1] + len < n
                        && c[sa[i - 1] + (len >> 1)] == c[sa[i] + (len >> 1)] ? classes[sa[i - 1]] : i;
            }
            int[] cnt = new int[n];
            for (int i = 0; i < n; i++) {
                cnt[i] = i;
            }
            //int[] s = sa.clone();
            int[] s = Arrays.copyOf(sa, n);
            for (int i = 0; i < n; i++) {
                int s1 = s[i] - len;
                if (s1 >= 0) {
                    sa[cnt[classes[s1]]++] = s1;
                }
            }
        }
        return sa;
    }

    static int[] lcp(int[] sa, char[] s) {
        int n = sa.length;
        int[] rank = new int[n];
        for (int i = 0; i < n; i++)
            rank[sa[i]] = i;
        int[] lcp = new int[n];

        for (int i = 0, h = 0; i < n; i++) {
            if (rank[i] < n - 1) {
                for (int j = sa[rank[i] + 1]; max(i, j) + h < s.length
                        && s[i + h] == s[j + h]; ++h)
                    ;
                lcp[rank[i] + 1] = h;
                if (h > 0)
                    --h;
            }
        }
        return lcp;
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }

    static class SegTree {
        Node root;
        int n;

        SegTree(int N) {
            n = N;
            root = new Node();
        }

        void pushDown(Node node, int s, int m, int e) {
            if (node.lazy == 0) return;
            if (node.left != null) {
                node.left.value += (m - s + 1) * node.lazy;
                node.left.lazy += node.lazy;
            }
            if (node.right != null) {
                node.right.value += (e - m) * node.lazy;
                node.right.lazy += node.lazy;
            }
            node.lazy = 0;
        }

        void update(int l, int r, int v) {
            update(root, 1, n, l, r, v);
        }

        void update(Node node, int s, int e, int a, int b, int value) {
            if (s > e || s > b || e < a) return;
            if (s >= a && e <= b) {
                node.lazy += value;
                node.value += (e - s + 1) * value;
                return;
            }
            int m = (s + e) / 2;
            if (node.left == null) node.left = new Node();
            if (node.right == null) node.right = new Node();
            pushDown(node, s, m, e);
            update(node.left, s, m, a, b, value);
            update(node.right, m + 1, e, a, b, value);
            node.value = node.left.value + node.right.value;
        }

        void clearRange(int l, int r) {
            root = clearRange(root, 1, n, l, r);
        }

        Node clearRange(Node node, int s, int e, int a, int b) {
            if (s > e || s > b || e < a) return node;
            if (s >= a && e <= b) {
                return new Node();
            }
            int m = (s + e) / 2;
            if (node.left == null) node.left = new Node();
            if (node.right == null) node.right = new Node();
            pushDown(node, s, m, e);
            node.left = clearRange(node.left, s, m, a, b);
            node.right = clearRange(node.right, m + 1, e, a, b);
            node.value = node.left.value + node.right.value;
            return node;
        }

        long query(int l, int r) {
            return query(root, 1, n, l, r);
        }

        long query(Node node, int s, int e, int a, int b) {
            if (s > e || s > b || e < a) return 0;
            if (s >= a && e <= b) {
                return node.value;
            }
            int m = (s + e) / 2;
            if (node.left == null) node.left = new Node();
            if (node.right == null) node.right = new Node();
            pushDown(node, s, m, e);
            return query(node.left, s, m, a, b) + query(node.right, m + 1, e, a, b);
        }

        static class Node {
            Node left, right;
            long value, lazy;

            Node() {
            }

            Node(int v) {
                value = v;
            }

            @Override
            public String toString() {
                return "[" + value + ", " + lazy + "]";
            }
        }
    }
}