#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long INF = 1ll << 60;
const double pi = acos(-1);
const double eps = 1e-9;
const long long mod = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int n, m;
map<long long, long long> a;
int main() {
  cin >> n >> m;
  int t = 0;
  a[0]++;
  for (int i = 0; i < n; i++) {
    int A;
    cin >> A;
    (t += A) %= m;
    a[t]++;
  }
  long long res = 0;
  for (auto i = a.begin(); i != a.end(); i++) {
    int x = i->second;
    res += x * (x - 1) / 2;
  }
  cout << res << endl;
}
