#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
int main() {
  int N, M;
  int64 A[100001] = {};
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  map<int64, int> mp;
  int64 sum = 0;
  mp[sum]++;
  int64 ret = 0;
  for (int i = 0; i < N; i++) {
    sum += A[i];
    sum %= M;
    ret += mp[(M - sum) % M];
    mp[sum]++;
  }
  cout << ret << endl;
}
