#include<bits/stdc++.h>
using namespace std;
long long subCount(long long arr[], long long n, long long k)
{
    // create auxiliary hash array to count frequency
    // of remainders
    long long mod[k];
    memset(mod, 0, sizeof(mod));
 
    // Traverse original array and compute cumulative
    // sum take remainder of this current cumulative
    // sum and increase count by 1 for this remainder
    // in mod[] array
    long long cumSum = 0;
    for (long long i = 0; i < n; i++) {
        cumSum += arr[i];
 
        // as the sum can be negative, taking modulo twice
        mod[((cumSum % k) + k) % k]++;
    }
 
    long long result = 0; // Initialize result
 
    // Traverse mod[]
    for (long long i = 0; i < k; i++)
 
        // If there are more than one prefix subarrays
        // with a particular mod value.
        if (mod[i] > 1)
            result += (mod[i] * (mod[i] - 1)) / 2;
 
    // add the elements which are divisible by k itself
    // i.e., the elements whose sum = 0
    result += mod[0];
 
    return result;
}

int main(){
	long long n,k;
	long long long a[n];
	for(long long i=0;i<n;i++)cin>>a[i];
	cout<<subCount(a,n,k)<<"\n";
	return 0;
}