#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 18;
const long long MAX = 200000;
const long long MOD = 1000000007;
static const double pi = 3.141592653589793;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  vector<long long> B(M, 0);
  B[0] = 1;
  long long Sum = 0;
  for (long long i = (0); i < (N); i++) {
    cin >> A[i];
    Sum += A[i];
    Sum %= M;
    B[Sum]++;
  }
  long long Ans = 0;
  for (long long i = (0); i < (M); i++) {
    Ans += B[i] * (B[i] - 1) / 2;
  }
  cout << Ans << endl;
}
