#include <bits/stdc++.h>
using namespace std;
int Set(int mask, int pos) { return mask = mask | (1 << pos); }
bool check(int mask, int pos) { return (bool)(mask & (1 << pos)); }
int arr[100005], dp[100005];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  int n, m;
  cin >> n >> m;
  map<int, int> make_pair;
  long long sum = 0;
  make_pair[0]++;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    sum += (long long)arr[i];
    dp[i] = dp[i - 1] + make_pair[sum % m];
    make_pair[sum % m]++;
  }
  cout << dp[n] << endl;
  return 0;
}
