#include <bits/stdc++.h>
using namespace std;
const int N_MAX = 100005;
const long long int INF = 999999999999999;
int main() {
  int n;
  long long int m, a[N_MAX];
  map<long long int, int> rem;
  vector<long long int> key, sum;
  cin >> n >> m;
  sum.push_back(0);
  rem[0]++;
  key.push_back(0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum.push_back(sum.back() + a[i]);
    long long int r = sum.back() % m;
    rem[r]++;
    key.push_back(r);
  }
  sort(key.begin(), key.end());
  long long int flg = -1, ans = 0;
  for (int i = 0; i < key.size(); i++) {
    if (rem[key[i]] >= 2 && key[i] != flg)
      ans += rem[key[i]] * (rem[key[i]] - 1) / 2;
    flg = key[i];
  }
  cout << ans << endl;
}
