#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>     
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  long long ans = 0;
  int s = 0;
  mp[0] = 1;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    s += a;
    s %= m;
    ans += mp[s];
    mp[s]++;
  }
  cout << ans << endl;
}