#include<bits/stdc++.h> #define debug(x) cout << #x << ":\t" << (x) << endl; usingnamespace std; #define ll long long constint N = 2e6 + 10; constint INF = 0x3f3f3f3f; const ll inf = 0x3f3f3f3f3f3f3f3f; const ll mod = 200003; constdouble PI = acos(-1.0); structComplex { double x, y; Complex(double _x = 0.0, double _y = 0.0) { x = _x; y = _y; } Complex operator-(const Complex &b) const { returnComplex(x - b.x, y - b.y); } Complex operator+(const Complex &b) const { returnComplex(x + b.x, y + b.y); } Complex operator*(const Complex &b) const { returnComplex(x * b.x - y * b.y, x * b.y + y * b.x); } }; voidchange(Complex y[], int len){ int i, j, k; for (i = 1, j = len / 2; i < len - 1; i++) { if (i < j) swap(y[i], y[j]); k = len / 2; while (j >= k) { j = j - k; k = k / 2; } if (j < k) j += k; } } voidfft(Complex y[], int len, int on){ //0-len-1 change(y, len); for (int h = 2; h <= len; h <<= 1) { Complex wn(cos(2 * PI / h), sin(on * 2 * PI / h)); for (int j = 0; j < len; j += h) { Complex w(1, 0); for (int k = j; k < j + h / 2; k++) { Complex u = y[k]; Complex t = w * y[k + h / 2]; y[k] = u + t; y[k + h / 2] = u - t; w = w * wn; } } } if (on == -1) { for (int i = 0; i < len; i++) { y[i].x /= len; } } } int m, n; int mp[N], mo[N]; int f[N], a[N]; Complex b[N << 2], c[N << 2]; intmain(){ scanf("%d", &m); int mx = 2 * mod, len = 1; while (len <= mx)len <<= 1; int p = 1; for (int i = 0; i < len; i++) { if (i < mod - 1)mp[p] = i; mo[i] = p; p = p * 2 % mod; } for (int i = 1; i <= m; i++) { int x; scanf("%d", &x); if (x)a[++n] = x; } for (int i = 1; i <= n; i++) { f[mp[a[i]]]++; } for (int i = 0; i < mod - 1; i++) { b[i] = { f[i] * 1.0,0.0 }; } fft(b, len, 1); for (int i = 0; i < len; i++)c[i] = b[i] * b[i]; fft(c, len, -1); ll ans = 0; for (int i = 0; i < len; i++) { ans += 1ll * mo[i] * (ll)(c[i].x + 0.5); } for (int i = 1; i <= n; i++) { ans -= 1ll * a[i] * a[i] % mod; } printf("%lld\n", ans / 2); return0; }