#include <bits/stdc++.h>
using namespace std;
const long long INF = 9223372036854775807;
const int inf = 2147483647;
int main() {
  int n, m;
  cin >> n >> m;
  long long a[100000];
  long long b[100001];
  long long res = 0;
  cin >> a[0];
  b[0] = a[0] % m;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    b[i] += (b[i - 1] + a[i]) % m;
  }
  sort(b, b + n);
  int cnt = 0;
  int cnt2 = 0;
  for (int i = 0; i < n + 1; i++) {
    if (b[i] == 0) {
      res -= max(0, cnt2 * (cnt2 - 1) / 2);
      res += max(0, cnt2 * (cnt2 + 1) / 2);
      cnt2++;
    } else {
      if (b[i] == b[i - 1]) {
        res -= max(0, ++cnt * (cnt - 1) / 2);
        res += max(0, cnt * (cnt + 1) / 2);
      } else {
        cnt = 0;
      }
    }
  }
  cout << res << endl;
  ;
  return 0;
}
