#include <bits/stdc++.h>
using namespace std;
int to_int(string s) { return atoi(s.c_str()); }
int a[100000];
long long int sum[100001];
int main() {
  int m, n;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  unordered_map<int, int> mp;
  sum[0] = 0;
  mp[0] = 1;
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + a[i];
    mp[sum[i + 1] % m] += 1;
  }
  long long int r = 0;
  for (int i = 0; i < n + 1; i++) {
    r += mp[sum[i] % m] * (mp[sum[i] % m] - 1) / 2;
    mp[sum[i] % m] = 0;
  }
  cout << r << endl;
}
