Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vl;
typedef vector<vector<ll>> vll;
typedef vector<bool> vb;
typedef set<int> si; 
typedef queue<int> qi;
typedef stack<int> sti;
typedef priority_queue<int> pqi;
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
//#define __builtin_popcountll bitCountLL
//#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
#define maxn 100005
#define Mod 1000000007
const int INF = 2e9;
const ll ML = 4e18;
const int p = 200003;
int Pow(int x, int r) {
    ll res = 1;
    while(r) {
        if(r & 1) res = (res * x) % p;
        x = (ll)x * x % p;
        r >>= 1;
    }
    return int(res);
}
struct comp{
    ld x, y;
    comp( ld x = .0, ld y = .0) : x(x), y(y) {}
    inline comp conj() { return comp(x, -y);}
};
inline comp operator + (const comp &a, const comp& b) {
    return comp(a.x + b.x, a.y + b.y);
}
inline comp operator - (const comp &a, const comp& b) {
    return comp(a.x - b.x, a.y - b.y);
}
inline comp operator * (const comp &a, const comp& b) {
    return comp(a.x * b.x - a.y * b.y, a.y * b.x + a.x * b.y);
}
inline comp operator / (const comp &a, const ld& b) {
    return comp(a.x / b, a.y / b);
}
const ld PI = acos(-1.0);
const int LOG = 20;
const int N = 1 << LOG;
vector<comp> w[LOG];
vi rv[LOG];
void precacl() {
    for(int i = 0; i < LOG; i++) {
        w[i].assign(1 << i,comp());
        for(int k = 0; k < (1 << i); k++) {
            ld ang =  PI / (1 << i) * k;
            w[i][k] = comp(cos(ang), sin(ang));
        }

        rv[i].assign(1u << i,0);
        if(i == 0) {
            rv[i][0] = 0;
            continue;
        }
        int h = 1 << (i - 1);
        for(int k = 0; k < (1 << i); k++) {
            rv[i][k] = (rv[i - 1][k & (h - 1)] << 1) | (k >= h);
        }
    }
}

void fft(vector<comp>& a, int n, int ln, bool flag) {
    for(int i = 0; i < n; i++) {
        int ni = rv[ln][i];
        if(i < ni) {
            swap(a[i],a[ni]);
        }
    }
    for(int i = 0; (1 << i) < n; i++) {
        int len = (1 << i);
        for(int k = 0; k < n; k += (len << 1)) {
            for(int pos = k; pos < k + len; pos++) {
                comp l = a[pos];
                comp r = a[pos + len] * (flag ? w[i][pos - k].conj() : w[i][pos - k]); 
                a[pos] = l + r;
                a[pos + len] = l - r;
            }
        }
    }
    if(flag) {
        for(int i = 0; i < n; i++) a[i] = a[i] / (ld)n;
    }
}

void multiply(vector<comp>& a, int sza, vector<comp>& b, int szb, vector<ll>>& c, int szc) {
    int n = 1, ln = 0;
    while(n < sza + szb) {
        n <<= 1, ln++;
    }
    vector<comp> aa(n), bb(n), cc(n);
    for(int i = 0; i < n; i++) {
        aa[i] = (i < sza ? a[i] : comp());
        bb[i] = (i < szb ? b[i] : comp());
    }
    fft(aa, n, ln, false);
    fft(bb, n, ln, false);
    for(int i = 0; i < n; i++) {
        cc[i] = aa[i] * bb[i];
    }
    fft(cc, n, ln, true);
    for(int i = 0; i < szc; i++) {
        c[i] = round(cc[i].x);
    }
}

void solve() {
    int n;
    cin >> n;
    vi mp(p,0);
    fori(i,1,p) {
        int x = Pow(2,i);
        mp[x] = i;
    }
    vi a(n), count(p,0);
    fori(i,0,n) {
        cin >> a[i];
        if(!a[i]) continue;
        int t = mp[a[i]];
        if(t > 0) count[t]++;
    }
    precacl();
    vector<comp> cnt(p);
    vl res(p * 2 - 1);
    fori(i,1,p) {
        cnt[i].x = count[i];
    }
    multiply(cnt,p,cnt,p, res,p * 2 - 1);
    ll ans = 0;
    ll x = 2;
    fori(i,2,2 * p - 1) {
        x  = (x << 1) % p;
        if(res[i] > 0) ans += (ll)x * res[i]; 
    }
    fori(i,0,n) ans -= (ll)a[i] * a[i] % p;
    cout << ans / 2 << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
//	freopen("D:\\data_in.txt", "r", stdin);
   
    solve();
   
    /*
    clock_t start,finish;
    start = clock();
    
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Compiler output:
a.cc:103:76: error: expected ',' or '...' before '>' token
  103 | void multiply(vector<comp>& a, int sza, vector<comp>& b, int szb, vector<ll>>& c, int szc) {
      |                                                                            ^~
a.cc: In function 'void multiply(std::vector<comp>&, int, std::vector<comp>&, int, std::vector<long long int>)':
a.cc:119:24: error: 'szc' was not declared in this scope; did you mean 'sza'?
  119 |     for(int i = 0; i < szc; i++) {
      |                        ^~~
      |                        sza
a.cc:120:9: error: 'c' was not declared in this scope
  120 |         c[i] = round(cc[i].x);
      |         ^
a.cc: In function 'void solve()':
a.cc:145:13: error: too many arguments to function 'void multiply(std::vector<comp>&, int, std::vector<comp>&, int, std::vector<long long int>)'
  145 |     multiply(cnt,p,cnt,p, res,p * 2 - 1);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:103:6: note: declared here
  103 | void multiply(vector<comp>& a, int sza, vector<comp>& b, int szb, vector<ll>>& c, int szc) {
      |      ^~~~~~~~