#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

namespace FastFourierTransform {
  using real = double;
 
  struct C {
    real x, y;
 
    C() : x(0), y(0) {}
 
    C(real x, real y) : x(x), y(y) {}
 
    inline C operator+(const C &c) const { return C(x + c.x, y + c.y); }
 
    inline C operator-(const C &c) const { return C(x - c.x, y - c.y); }
 
    inline C operator*(const C &c) const { return C(x * c.x - y * c.y, x * c.y + y * c.x); }
 
    inline C conj() const { return C(x, -y); }
  };
 
  const real PI = acosl(-1);
  int base = 1;
  vector< C > rts = { {0, 0},
                     {1, 0} };
  vector< int > rev = {0, 1};
 
 
  void ensure_base(int nbase) {
    if(nbase <= base) return;
    rev.resize(1 << nbase);
    rts.resize(1 << nbase);
    for(int i = 0; i < (1 << nbase); i++) {
      rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
    }
    while(base < nbase) {
      real angle = PI * 2.0 / (1 << (base + 1));
      for(int i = 1 << (base - 1); i < (1 << base); i++) {
        rts[i << 1] = rts[i];
        real angle_i = angle * (2 * i + 1 - (1 << base));
        rts[(i << 1) + 1] = C(cos(angle_i), sin(angle_i));
      }
      ++base;
    }
  }
 
  void fft(vector< C > &a, int n) {
    assert((n & (n - 1)) == 0);
    int zeros = __builtin_ctz(n);
    ensure_base(zeros);
    int shift = base - zeros;
    for(int i = 0; i < n; i++) {
      if(i < (rev[i] >> shift)) {
        swap(a[i], a[rev[i] >> shift]);
      }
    }
    for(int k = 1; k < n; k <<= 1) {
      for(int i = 0; i < n; i += 2 * k) {
        for(int j = 0; j < k; j++) {
          C z = a[i + j + k] * rts[j + k];
          a[i + j + k] = a[i + j] - z;
          a[i + j] = a[i + j] + z;
        }
      }
    }
  }
 
  vector< int64_t > multiply(const vector< ll > &a, const vector< ll > &b) {
    int need = (int) a.size() + (int) b.size() - 1;
    int nbase = 1;
    while((1 << nbase) < need) nbase++;
    ensure_base(nbase);
    int sz = 1 << nbase;
    vector< C > fa(sz);
    for(int i = 0; i < sz; i++) {
      int x = (i < (int) a.size() ? a[i] : 0);
      int y = (i < (int) b.size() ? b[i] : 0);
      fa[i] = C(x, y);
    }
    fft(fa, sz);
    C r(0, -0.25 / (sz >> 1)), s(0, 1), t(0.5, 0);
    for(int i = 0; i <= (sz >> 1); i++) {
      int j = (sz - i) & (sz - 1);
      C z = (fa[j] * fa[j] - (fa[i] * fa[i]).conj()) * r;
      fa[j] = (fa[i] * fa[i] - (fa[j] * fa[j]).conj()) * r;
      fa[i] = z;
    }
    for(int i = 0; i < (sz >> 1); i++) {
      C A0 = (fa[i] + fa[i + (sz >> 1)]) * t;
      C A1 = (fa[i] - fa[i + (sz >> 1)]) * t * rts[(sz >> 1) + i];
      fa[i] = A0 + A1 * s;
    }
    fft(fa, sz >> 1);
    vector< int64_t > ret(need);
    for(int i = 0; i < need; i++) {
      ret[i] = llround(i & 1 ? fa[i >> 1].y : fa[i >> 1].x);
    }
    return ret;
  }
};

ll modpow(ll x,ll n,ll mo){
    if(n==0) return 1;
    else{
        return modpow(x*x % mo,n/2,mo)*(n%2?x:1)%mo;
    }
}

vector<ll> prime_factorize(ll n){
    vector<ll> res;
    for(ll a=2;a*a<=n;a++){
        if(n%a!=0) continue;
        while(n%a==0){
            n/=a;
        }
        res.push_back(a);
    }
    if(n!=1) res.push_back(n);
    return res;
}

//最小原始根
ll MinimumPrimitiveRoot(ll p){
    vector<ll> pfactlist = prime_factorize(p-1);
    ll len=(ll)pfactlist.size();
    ll a=2;
    ll i=0;
    while(i!=len){
        if(modpow(a,(p-1)/pfactlist[i],p)==1){
            a++;
            i=0;
        }
        else i++;
    }
    return a;
}

int main()
{
    ll p=200003;
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll r=MinimumPrimitiveRoot(p);
    
    vector<ll> trans(p);
    trans[0]=0;
    ll tmp=1;
    for(ll i=1;i<p;i++){
        tmp=(tmp*r)%p;
        trans[tmp]=i;
    }
    vector<ll> b(n);
    rep(i,n) b[i]=trans[a[i]];
    vector<ll> s(p);
    rep(i,n) if(b[i]) s[b[i]]++;
    
    auto c=FastFourierTransform::multiply(s,s);
    vector<ll> rui(2*p-2);
    rep(i,2*p-1){
        if(i==0) rui[i]=1;
        else rui[i]=rui[i-1]*r%p;
    }
    ll ans=0;
    rep(i,2*p-1){
        ans+=c[i]*rui[i];
    }
    rep(i,p){
        ans-=s[i]*rui[2*i]; //double counting
    }
    ans/=2; //perm→comb
    cout << ans << endl;
    return 0;
} 


Measured memory_bytes: 31604