#include <bits/stdc++.h>
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const long long LL_INF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  unsigned long long A[100005];
  for (int i = 0; i < (N); i++) {
    cin >> A[i + 1];
  }
  N++;
  A[0] = 0;
  map<int, int> mp;
  for (int i = 0; i < (N); i++) {
    if (i) A[i] += A[i - 1];
    mp[A[i] % M]++;
  }
  unsigned long long ans = 0;
  for (auto m : mp) {
    int a = m.second;
    ans += a * (a - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
