#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int const MOD = 998244353;

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

int main() {
    ll N;
    cin >> N;
    ll MAX = 0;
    vector<ll> D(N, 0);
    rep(i, N) {
        ll d;
        cin >> d;

        if ((i == 0 && d != 0) || (i != 0 && d == 0)) {
            cout << 0 << endl;
            return 0;
        }

        MAX = max(MAX, d);
        ++D[d];
    }

    ll ans = 1;
    rep(i, MAX + 1) {
        if (i == 0) continue;

        if (D[i] == 0) {
            ans = 0;
            break;
        }

        ans = (ans * modpow(D[i - 1], D[i])) % MOD;
    }

    cout << ans << endl;
}
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
using namespace std;
typedef long long ll;
int N;
map<ll, int> h;
vector<ll> v;
string s;
pair<ll, ll> frac[200100];
ll cnt[110][110];

pair<ll, ll> getFrac(string &s) {
  ll x = 0, y = 1;
  bool dec = false;
  for(int i=0;i<s.size();++i) {
    if(s[i] == '.') {
      dec = true;
      continue;
    }
    x = x*10 + (s[i] - '0');
    if(dec) y = y*10;
  }
  ll d = __gcd(x, y);
  x /= d; y /= d;
  if(!h[y]) {
    h[y] = 1;
    v.pb(y);
  }
  return mp(x, y);
}

int main() {
  cin>>N;
  ll ret = 0;
  for(int i=0;i<N;++i) {
    cin>>s;
    frac[i] = getFrac(s);
  }
  sort(v.begin(), v.end());
  for(int i=0;i<v.size();++i) h[v[i]] = i;
  for(int i=0;i<N;++i) {
    ll a = frac[i].fs, b = frac[i].sc;
    for(int j=0;j<v.size();++j) {
      if(a % v[j] == 0) {
        ret += cnt[h[b]][j];
      }
    }
    for(int j=0;j<v.size();++j) {
      if(a % v[j] == 0) {
        ++cnt[j][h[b]];
      }
    }
  }
  cout<<ret<<"\n";
}