#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 5;
long long a[maxn], sum[maxn], ans;
map<int, int> num;
int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    sum[i] = (sum[i - 1] + a[i]) % m;
    num[sum[i]]++;
  }
  ans = (1 + num[0]) * (num[0]) / 2;
  for (map<int, int>::iterator iter = num.begin(); iter != num.end(); ++iter) {
    if (iter->first == 0) {
      continue;
    }
    ans += iter->second * (iter->second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
