#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}
  void unionSet(int x, int y) {
    x = root(x), y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
  }
  bool findSet(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};
int gcd(int a, int b) {
  if (a < b) swap(a, b);
  int k = a % b;
  if (k == 1) return 1;
  if (k == 0) return b;
  int ans = gcd(b, k);
  return ans;
}
int digisum(long long a) {
  int sum = 0;
  while (a) {
    sum += a % 10;
    a /= 10;
  }
  return sum;
}
long long a[114514] = {};
long long b[100000010] = {};
int main() {
  int n, m;
  cin >> n >> m;
  a[0] = 0;
  b[0] = 1;
  long long ans = 0;
  for (int i = 1; i < n + 1; i++) {
    int x;
    cin >> x;
    x = x % m;
    ans += b[x];
    a[i] = (a[i - 1] + x) % m;
    b[a[i]]++;
  }
  cout << ans << endl;
}
