#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline void add(T& a, T b) {
  a = ((a + b) % 1000000007 + 1000000007) % 1000000007;
};
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, M;
  cin >> N >> M;
  map<long long, long long> mp;
  long long sum = 0;
  mp[0]++;
  for (int i = 0; i < N; i++) {
    long long a;
    cin >> a;
    sum += a;
    mp[sum % M]++;
  }
  long long ans = 0;
  for (auto x : mp) {
    ans += x.second * (x.second - 1) / 2LL;
    ans %= 1000000007;
  }
  cout << ans << endl;
}
