#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, A;
  long long count = 0, ans = 0;
  map<long long, int> mp;
  mp[0]++;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> A;
    count += A;
    count = count % M;
    mp[count]++;
  }
  for (auto it = mp.begin(); it != mp.end(); it++) {
    ans += (it->second - 1) * it->second / 2;
  }
  cout << ans;
}
