#include <bits/stdc++.h>
using namespace std;
int n, M;
int arr[100001];
int pref[100001];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> M;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    arr[i] %= M;
    sum += arr[i] % M;
    sum %= M;
    pref[i] = sum % M;
  }
  map<int, int> appearances;
  appearances[0] = 1;
  int counter = 0;
  for (int i = 0; i < n; i++) {
    counter += appearances[pref[i]];
    appearances[pref[i]]++;
  }
  cout << counter << endl;
}
