#include <bits/stdc++.h>
using namespace std;
int N, M;
unordered_map<int, int> mp;
int main() {
  cin >> N >> M;
  long long sum = 0;
  mp[0]++;
  for (int i = 0; i < (int)(N); i++) {
    int a;
    cin >> a;
    sum = (sum + a) % M;
    mp[sum]++;
  }
  long long ans = 0;
  for (auto e : mp) {
    int cnt = e.second;
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
}
