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