#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int A[100001] = {};
  long long B[100001] = {};
  map<int, int> MAP;
  for (int i = 0; i < (N); i++) {
    cin >> A[i];
    B[i + 1] = B[i] + A[i];
    B[i + 1] %= M;
    MAP[(int)B[i + 1]]++;
  }
  MAP[0]++;
  long long result = 0;
  for (auto ITR : MAP) {
    result += ITR.second * (ITR.second - 1) / 2;
  }
  cout << result << endl;
  return 0;
}
