#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <bits/stdc++.h>

using namespace std;

const int MOD = 200003;

struct Complex {
    double x, y;
    Complex(double _x = 0.0, double _y = 0.0) {
        x = _x; y = _y;
    }
    Complex operator -(const Complex& b)const {
        return Complex(x - b.x, y - b.y);
    }
    Complex operator +(const Complex& b)const {
        return Complex(x + b.x, y + b.y);
    }
    Complex operator *(const Complex& b)const {
        return Complex(x * b.x - y * b.y, x * b.y + y * b.x);
    }
};

void change(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 -= k;
            k /= 2;
        }
        if (j < k) j += k;
    }
}

void fft(Complex y[], int len, int on) {
    change(y, len);
    const double pi = acos(-1.0);
    for (int h = 2; h <= len; h <<= 1) {
        Complex wn(cos(-on * 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 vals[MOD];
int idx[MOD];

void find_radix() {
    for (int radix = 2; radix < MOD; ++radix) {
        int ok = 1;
        vals[0] = 1;
        for (int i = 1; i < MOD - 1; i++) {
            vals[i] = (long long)vals[i - 1] * radix % MOD;
            if (vals[i] == 1) {
                ok = 0;
                break;
            }
        }
        if (!ok) {
            continue;
        }
        memset(idx, -1, sizeof(idx));
        for (int i = 0; i < MOD - 1; i++) {
            idx[vals[i]] = i;
        }
        for (int i = 1; i < MOD; ++i) {
            assert(idx[i] >= 0);
        }
        break;
    }
}

const int L = (1 << 20);
int c[L];
Complex x[L];

int main()
{
#ifdef _MSC_VER
    freopen("c.in", "r", stdin);
#endif
    std::ios::sync_with_stdio(false);
    find_radix();
    int n;
    cin >> n;
    long long self = 0;
    memset(c, 0, sizeof(c));
    for (int i = 0; i < n; i++) {
        int val;
        cin >> val;
        if (val != 0) {
            ++c[idx[val]];
            self += (long long)val * val % MOD;
        }
    }
    long long ret = 0;
    for (int i = 0; i < MOD; i++) {
        if (c[i] > 10000) {
            ret += (long long)c[i] * (long long)c[i] * vals[(i + i) % (MOD - 1)];
            long long s = 0;
            for (int j = 0; j < MOD; j++) {
                if (i != j) {
                    s += (long long)c[j] * vals[(i + j) % (MOD - 1)];
                }
            }
            ret += (long long)c[i] * 2LL * s;
            c[i] = 0;
        }
    }
    memset(x, 0, sizeof(x));
    for (int i = 0; i < L; i++) {
        x[i].x = c[i];
    }
    fft(x, L, 1);
    for (int i = 0; i < L; i++) {
        x[i] = x[i] * x[i];
    }
    fft(x, L, -1);

    for (int i = 0; i < L; i++) {
        if (x[i].x > 0.5) {
            long long c = (long long)(x[i].x + 0.5);
            ret += c * vals[i % (MOD - 1)];
        }
    }
    cout << (ret - self) / 2 << endl;
    return 0;
}


Measured memory_bytes: 26056