Denote a cyclic sequence of size n as an array s such that s_n is adjacent to s_1. The segment s[r, l] where l < r is the concatenation of s[r, n] and s[1, l].

You are given an array a consisting of n integers. Define b as the cyclic sequence obtained from concatenating m copies of a. Note that b has size n ⋅ m.

You are given an integer k where k = 1 or k is a prime number. Find the number of different segments in b where the sum of elements in the segment is divisible by k.

Two segments are considered different if the set of indices of the segments are different. For example, when n = 3 and m = 2, the set of indices for segment s[2, 5] is \{2, 3, 4, 5\}, and for segment s[5, 2] is \{5, 6, 1, 2\}. In particular, the segments s[1, 6], s[2,1], …, s[6, 5] are considered as the same segment.

Output the answer modulo 10^9 + 7.

Input

The first line contains three integers n, m, and k (1 ≤ n, m, k ≤ 2 ⋅ 10^5, k = 1 or k is a prime number).

The second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 2 ⋅ 10^5).

Output

Output an integer denoting the number of different segments in b where the sum of elements in the segment is divisible by k, modulo 10^9 + 7.

Examples

Input


5 1 5
1 2 3 4 3


Output


4


Input


5 1 5
1 2 3 4 5


Output


5


Input


5 4 5
1 2 3 4 5


Output


125

Note

In the first example, all valid segments are [1,4], [2, 3], [3, 5], and [4, 2].

In the second example, one of the valid segments is [1, 5].
#include <bits/stdc++.h>
using namespace std;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }
const int maxn = 1e6 + 7, inf = 0x3f3f3f3f, mod = 1e9 + 7;
const int MAXN = 200005;
const long double PI = acos(-1);
const long long MOD = 1000000007;
struct Complex {
  long double real, imag;
  Complex(long double R = 0, long double I = 0) {
    real = R;
    imag = I;
  }
  Complex operator+(const Complex &p) const {
    return Complex(real + p.real, imag + p.imag);
  }
  Complex operator-(const Complex &p) const {
    return Complex(real - p.real, imag - p.imag);
  }
  Complex operator*(const Complex &p) const {
    return Complex(real * p.real - imag * p.imag,
                   real * p.imag + imag * p.real);
  }
} f[MAXN << 2], g[MAXN << 2], h[MAXN << 2], wn[2][MAXN << 2];
int n, m, k, N;
int c[MAXN];
int d[MAXN];
int cnt2[MAXN];
int cnt3[MAXN];
int rev[MAXN << 2];
long long cnt[MAXN];
void FFTinit(int l) {
  N = 1;
  while (N < l) N <<= 1;
  for (int i = 1; i < N; i++) rev[i] = (rev[i >> 1] >> 1) + (i & 1) * (N >> 1);
  int half = N >> 1;
  for (int i = 0; i < half; i++) {
    wn[0][half + i] = Complex(cos(PI * i / half), sin(PI * i / half));
    wn[1][half + i] = Complex(cos(PI * i / half), -sin(PI * i / half));
  }
  for (int i = half - 1; i >= 0; i--) {
    wn[0][i] = wn[0][i << 1];
    wn[1][i] = wn[1][i << 1];
  }
}
void FFT(Complex *v, int inv) {
  for (int i = 0; i < N; i++)
    if (i < rev[i]) swap(v[i], v[rev[i]]);
  for (int i = 1; i < N; i <<= 1)
    for (int j = 0; j < N; j += (i << 1)) {
      Complex *l = v + j, *r = v + j + i, *w = wn[inv == -1] + i, A;
      for (int k = 0; k < i; k++, l++, r++, w++) {
        A = *w * *r;
        *r = *l - A;
        *l = *l + A;
      }
    }
  if (inv == -1) {
    Complex Inv(1.0 / N, 0);
    for (int i = 0; i < N; i++) v[i] = v[i] * Inv;
  }
}
int a[maxn], pre[maxn], lst[maxn];
long long res[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    pre[i] = (pre[i - 1] + a[i]) % k;
  }
  long long ans = 0;
  if (m == 1) {
    if (pre[n] == 0) ans = 1;
    for (int i = n + 1; i <= 2 * n; ++i)
      a[i] = a[i - n], pre[i] = (pre[i - 1] + a[i]) % k;
    map<int, int> vis;
    vis[0] = 1;
    for (int i = 1; i < 2 * n; ++i) {
      if (i - n >= 0) {
        vis[pre[i - n]]--;
        ans = (ans + vis[pre[i]]) % mod;
      }
      vis[pre[i]]++;
    }
    cout << ans << '\n';
  } else {
    for (int i = n; i >= 1; --i) {
      lst[i] = (lst[i + 1] + a[i]) % k;
    }
    FFTinit(k * 3 + 3);
    for (int i = 1; i <= n; ++i) {
      f[pre[i]].real++;
      h[lst[i]].real++;
    };
    for (int i = 0; i <= m - 2; ++i) g[1ll * pre[n] * i % k].real++;
    FFT(f, 1), FFT(h, 1), FFT(g, 1);
    for (int i = 0; i < N; ++i) f[i] = f[i] * h[i] * g[i];
    FFT(f, -1);
    for (int i = 0; i < N; ++i)
      res[i % k] = (res[i % k] + (long long)(f[i].real + 0.5) % mod) % mod;
    ans = res[0] * m % mod;
    ;
    if ((pre[n] * m) % k == 0) ans++;
    map<int, int> vis;
    vis[0] = 1;
    int tmp = 0;
    for (int i = 1; i <= n; ++i) {
      tmp = (tmp + vis[pre[i]]) % mod;
      vis[pre[i]]++;
    };
    ans = (ans + 1ll * tmp * m % mod) % mod;
    cout << ans << '\n';
  }
  return 0;
}
