#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e+14;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  long long M;
  cin >> M;
  long long A[100100], B[100100];
  B[0] = 0;
  map<long long, long long> m;
  map<long long, long long>::iterator ite;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i + 1] = B[i] + A[i];
    B[i + 1] %= M;
    m[B[i + 1]]++;
  }
  long long ans = 0;
  for (ite = m.begin(); ite != m.end(); ite++) {
    if (ite->second >= 2) {
      long long x = ite->second;
      long long X = x * (x - 1) / 2;
      ans += X;
    }
  }
  cout << ans << "\n";
  return 0;
}
