/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

// 約数列挙
vector<int> get(int n) {
    vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

class FGCDOrMIN {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> A(N);
        REP(i, N) cin >> A[i];

        int mina = INF;
        map<int, int> m;
        REP(i, N) {
            for (auto n : get(A[i])) {
                if (m.count(n) == 0) {
                    m[n] = A[i];
                } else {
                    m[n] = gcd(m[n], A[i]);
                }
            }
            mina = min(mina, A[i]);
        }
        int res = 0;
        for (auto kv : m) {
            if (kv.second <= mina && kv.first == kv.second) {
                res++;
            }
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FGCDOrMIN solver;
    solver.solve(in, out);
    return 0;
}

#include <bits/stdc++.h>
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
 
//define
#define trav(i,v)   for(auto i: v)
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()
#define itn int 
 
//typedef
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long inf = 1000000000000000000;
 
using namespace std;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

void init()
{

}

void solve()
{
    int n, m;
    cin>>n>>m;
    vll a(n+1);
    repu(i,1,n)
        cin>>a[i];
    vi v[n+1], vv[n+1];
    vi in(n+1,0), out(n+1,0);
    rep(i,m)
    {
        int x, y;
        cin>>x>>y;
        in[y]++;
        out[x]++;
        v[x].pb(y);
        vv[y].pb(x);
    }
    vll v1(n+1,inf), v2(n+1,0);
    repu(i,1,n)
    {
        v1[i] = inf;
        v2[i] = a[i];
    }
    vi vis(n+1,0);
    set<int> s;
    repu(i,1,n)
    {
        if(in[i]==0)
        {
            s.insert(i);
            v1[i] = inf;
        }
    }
    while(!s.empty())
    {
        int x = *s.begin();
        if(vis[x])
            continue;
        vis[x] = 1;
        s.erase(s.begin());
        trav(y,v[x])
        {
            s.insert(y);
            v1[y] = min(v1[y],min(v1[x],a[x]));
        }
    }
    // cout<<v1[3]<<" "<<v2[3]<<endl;
    
    ll ans = -inf;
    repu(i,1,n)
    {
        ans = max(v2[i]-v1[i],ans);
    }
    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;    
    init();
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}