#include <bits/stdc++.h>
using ll = long long;
constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
constexpr long double eps = 1e-9;
const long double PI = acosl(-1.0L);
using namespace std;
void scans(string& str) {
  char c;
  str = "";
  scanf("%c", &c);
  if (c == '\n') scanf("%c", &c);
  while (c != '\n' && c != -1 && c != ' ') {
    str += c;
    scanf("%c", &c);
  }
}
void scanc(char& str) {
  char c;
  scanf("%c", &c);
  if (c == -1) return;
  while (c == '\n') {
    scanf("%c", &c);
  }
  str = c;
}
double acot(double x) { return PI / 2 - atan(x); }
ll LSB(ll n) { return (n & (-n)); }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n + 1);
  int b, ans = 0;
  map<int, int> mp;
  ++mp[0];
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &b);
    a[i + 1] = a[i] + b;
    a[i + 1] %= m;
    ans += mp[a[i + 1]];
    ++mp[a[i + 1]];
  }
  printf("%d\n", ans);
  return 0;
}
