#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1;
const long long MOD = 1e9 + 7;
const double PI = 3.141592653589793;
int main() {
  int n, m;
  cin >> n >> m;
  int box[110000];
  map<int, int> mp;
  long long ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    int a;
    cin >> a;
    a = a % m;
    box[i] = i == 0 ? a : (box[i - 1] + a) % m;
    mp[box[i]]++;
    if (box[i] == 0) ans++;
  }
  for (pair<int, int> x : mp) {
    ans += x.second * (x.second - 1) / 2;
  }
  cout << ans << endl;
}
