#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int X10 = 1024, X11 = 2048, X12 = 4096, X13 = 8196, X14 = 16392,
          X15 = 32786, X16 = 65536, X17 = 131072, X18 = 262144, X19 = 524288,
          X20 = 1048576;
class UnionFind {
 private:
  vector<int> p, rank;
  int N;
  int findSet2(int i, bool* A) {
    A[i] = 1;
    return (p[i] == i) ? i : (p[i] = findSet2(p[i], A));
  }

 public:
  UnionFind(int N) {
    rank.assign(N, 0);
    p.assign(N, 0);
    for (int i = 0; i < N; i++) p[i] = i;
    this->N = N;
  }
  int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
  bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  void unionSet(int i, int j) {
    if (!isSameSet(i, j)) {
      int x = findSet(i), y = findSet(j);
      if (rank[x] > rank[y])
        p[y] = x;
      else {
        p[x] = y;
        if (rank[x] == rank[y]) rank[y]++;
      }
    }
  }
  int numDisjointSets() {
    set<int> s;
    bool* visited = new bool[this->N];
    memset(visited, 0, sizeof(bool) * this->N);
    for (int i = 0; i < N; ++i) {
      if (!visited[i]) s.insert(findSet2(i, visited));
    }
    return s.size();
  }
  int maxElements() {
    int mx = 0;
    map<int, int> m;
    for (int i = 0; i < N; ++i) {
      m[findSet(i)]++;
    }
    set<pair<int, int>> s;
    for (auto p : m) {
      s.insert({p.second, p.first});
    }
    return s.rbegin()->first;
  }
};
ushort mod[1000000000];
long long subCount(long long arr[], long long n, long long k) {
  long long cumSum = 0;
  for (int i = 0; i < n; i++) {
    cumSum += arr[i];
    mod[((cumSum % k) + k) % k]++;
  }
  long long result = 0;
  for (int i = 0; i < k; i++)
    if (mod[i] > 1) result += (mod[i] * (mod[i] - 1)) / 2;
  result += mod[0];
  return result;
}
long long A[100000];
void _() {
  long long a, b;
  cin >> a >> b;
  for (int i = 0; i < a; ++i) {
    cin >> A[i];
  }
  cout << subCount(A, a, b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  _();
  return 0;
}
