#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long A[10004];
  long long sum[10004] = {0};
  map<long long int, long long int> mp;
  mp[0]++;
  long long m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
  }
  long long int count = 0;
  for (int j = 1; j <= n; j++) {
    sum[j] = sum[j - 1] + A[j];
    long long int temp = sum[j] % m;
    count += mp[temp];
    mp[temp]++;
  }
  cout << count;
  return 0;
}
