#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long A[10004];
  map<long long int, long long int> mp;
  mp[0]++;
  long long m;
  cin >> n >> m;
  long long int count = 0;
  long long int temp = 0;
  for (int j = 1; j <= n; j++) {
    cin >> A[j];
    temp = temp + A[j];
    temp = temp % m;
    count += mp[temp];
    mp[temp]++;
  }
  cout << count;
  return 0;
}
