#include <stdio.h>

#define MAX_SIZE 101

int main() {
    int N, M;
    scanf("%d %d", &N, &M);

    int hash_table[MAX_SIZE];
    // Initialize hash table with -1 (empty)
    for(int i = 0; i < N; i++) {
        hash_table[i] = -1;
    }

    long long total_probes = 0;

    for (int k = 0; k < M; k++) {
        int key;
        scanf("%d", &key);

        int h1 = key % N;
        int h2 = 1 + (key % (N - 1)); // Secondary hash for the step size

        int i = 0;
        while (1) { // Loop until an empty slot is found
            int idx = (h1 + i * h2) % N;
            total_probes++; // Each check counts as one probe
            if (hash_table[idx] == -1) {
                hash_table[idx] = key;
                break; // Exit loop once key is inserted
            }
            i++; // Move to the next probe position
        }
    }

    printf("%lld\n", total_probes);
    return 0;
}