// editor2


#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int N, M;
    if (scanf("%d", &N) != 1) return 0;
    if (scanf("%d", &M) != 1) return 0;

    
    int table = (int)malloc(N * sizeof(int));
    if (!table) return 0;
    for (int i = 0; i < N; ++i) table[i] = -1;

    long long total_probes = 0;

    for (int k = 0; k < M; ++k) {
        int key;
        scanf("%d", &key);

        // primary hash
        int h1 = (N == 0) ? 0 : (key % N);

        // secondary hash (avoid modulo by zero when N == 1)
        int h2;
        if (N == 1) h2 = 1;
        else h2 = 1 + (key % (N - 1));

        // try up to N probes (i = 0 .. N-1)
        int inserted = 0;
        for (int i = 0; i < N; ++i) {
            int pos = (int)((h1 + (long long)i * h2) % N);
            total_probes++;                // every slot check counts as a probe
            if (table[pos] == -1) {
                table[pos] = key;
                inserted = 1;
                break;
            }
            // otherwise continue probing
        }
        // if not inserted after N probes, we simply continue;
        // problem constraints (M <= N) normally prevent permanent failure.
    }

    printf("%lld\n", total_probes);

    free(table);
return 0;
}