Yura has a team of k developers and a list of n tasks numbered from 1 to n. Yura is going to choose some tasks to be done this week. Due to strange Looksery habits the numbers of chosen tasks should be a segment of consecutive integers containing no less than 2 numbers, i. e. a sequence of form l, l + 1, ..., r for some 1 ≤ l < r ≤ n. 

Every task i has an integer number ai associated with it denoting how many man-hours are required to complete the i-th task. Developers are not self-confident at all, and they are actually afraid of difficult tasks. Knowing that, Yura decided to pick up a hardest task (the one that takes the biggest number of man-hours to be completed, among several hardest tasks with same difficulty level he chooses arbitrary one) and complete it on his own. So, if tasks with numbers [l, r] are chosen then the developers are left with r - l tasks to be done by themselves. 

Every developer can spend any integer amount of hours over any task, but when they are done with the whole assignment there should be exactly ai man-hours spent over the i-th task. 

The last, but not the least problem with developers is that one gets angry if he works more than another developer. A set of tasks [l, r] is considered good if it is possible to find such a distribution of work that allows to complete all the tasks and to have every developer working for the same amount of time (amount of work performed by Yura doesn't matter for other workers as well as for him).

For example, let's suppose that Yura have chosen tasks with following difficulties: a = [1, 2, 3, 4], and he has three developers in his disposal. He takes the hardest fourth task to finish by himself, and the developers are left with tasks with difficulties [1, 2, 3]. If the first one spends an hour on the first task and an hour on the third one, the second developer spends two hours on the second task and the third developer spends two hours on the third task, then they are done, since every developer worked exactly for two hours and every task has been worked over for the required amount of time. As another example, if the first task required two hours instead of one to be completed then it would be impossible to assign the tasks in a way described above. 

Besides work, Yura is fond of problem solving. He wonders how many pairs (l, r) (1 ≤ l < r ≤ n) exists such that a segment [l, r] is good? Yura has already solved this problem, but he has no time to write the code. Please, help Yura and implement the solution for this problem. 

Input

The first line of input contains two positive integers: n and k (1 ≤ n ≤ 300 000, 1 ≤ k ≤ 1 000 000), the number of tasks in the list and the number of developers in Yura's disposal. 

The second line contains n integers ai (1 ≤ ai ≤ 109). 

Output

Output a single integer — the number of pairs (l, r) satisfying the conditions from the statement.

Examples

Input

4 3
1 2 3 4


Output

3


Input

4 2
4 4 7 4


Output

6

Note

In the first sample there are three good segments:

  1. [1;3] — the hardest task requires 3 man-hours, so there are tasks left that require 1 and 2 man-hours. A solution is to make first developer work on the first task for an hour, while second and third developers work on the second task. Each developer works exactly one hour.
  2. [1;4] — the hardest task requires 4 man-hours, so there are tasks left that require 1, 2 and 3 man-hours. If the first developer spends an hour on the first task and an hour on the third one, the second developer spends two hours on the second task and the third developer spends two hours on the third task, then they are done, since every developer worked exactly for two hours.
  3. [3;4] — the hardest task requires 4 man-hours, so there is only one task left that requires 3 man-hours. A solution is to make each developer work for an hour.
#include <bits/stdc++.h>
using namespace std;
const int inf = int(1e9);
const double eps = 1e-9;
const double pi = 4 * atan(double(1));
const int N = int(3e5) + 100;
int murmur(int x) {
  x ^= x >> 16;
  x *= -2048144789;
  x ^= x >> 13;
  x *= -1028477387;
  x ^= x >> 16;
  return x;
}
struct open_map {
  int n, sz;
  bool* used;
  int* val;
  int* cnt;
  open_map() {
    n = 16;
    used = new bool[n];
    val = new int[n];
    cnt = new int[n];
    for (int i = 0; i < n; ++i) {
      used[i] = false;
    }
    sz = 0;
  }
  int get(int nval) {
    int pos = murmur(nval) & (n - 1);
    while (used[pos]) {
      if (val[pos] == nval) {
        return cnt[pos];
      }
      pos = (pos + 1) & (n - 1);
    }
    return 0;
  }
  void clear() {
    n = sz = 0;
    delete[] used;
    delete[] val;
    delete[] cnt;
  }
  void add(int cval) {
    int pos = murmur(cval) & (n - 1);
    while (used[pos]) {
      if (val[pos] == cval) {
        ++cnt[pos];
        return;
      }
      pos = (pos + 1) & (n - 1);
    }
    if (sz + 1 + 1 >= 0.75 * n) {
      bool* nused = new bool[n * 2];
      int* nval = new int[n * 2];
      int* ncnt = new int[n * 2];
      for (int i = 0; i < n * 2; ++i) {
        nused[i] = false;
      }
      for (int i = 0; i < n; ++i) {
        if (used[i]) {
          int pos = murmur(val[i]) & ((n * 2) - 1);
          while (nused[pos]) {
            pos = (pos + 1) & ((n * 2) - 1);
          }
          nused[pos] = true;
          nval[pos] = val[i];
          ncnt[pos] = cnt[i];
        }
      }
      delete[] used;
      delete[] val;
      delete[] cnt;
      used = nused;
      val = nval;
      cnt = ncnt;
      n *= 2;
      add(cval);
      return;
    }
    used[pos] = true;
    val[pos] = cval;
    cnt[pos] = 1;
    ++sz;
  }
};
struct seg {
  int l, r;
  open_map L, R;
};
pair<int, int> a[N];
int col[N], sum[N];
seg s[N];
inline int get_cnt(open_map& map, int val) { return map.get(val); }
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    int cur;
    scanf("%d", &cur);
    sum[i] = ((i > 0 ? sum[i - 1] : 0) + cur) % k;
    a[i] = make_pair(cur, i);
  }
  sort(a, a + n);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    col[i] = -1;
  }
  int ptr = 0;
  for (int i = 0; i < n; ++i) {
    int pos = a[i].second;
    int l = pos, r = pos;
    if (pos > 0 && col[pos - 1] != -1) {
      l = s[col[pos - 1]].l;
    }
    if (pos + 1 < n && col[pos + 1] != -1) {
      r = s[col[pos + 1]].r;
    }
    if (pos - l < r - pos) {
      int cur_col;
      if (r > pos) {
        cur_col = col[r];
      } else {
        cur_col = ptr++;
      }
      for (int j = l; j <= pos; ++j) {
        int need = (a[i].first + (j > 0 ? sum[j - 1] : 0)) % k;
        if (j < pos && sum[pos] == need) {
          ++ans;
        }
        if (r > pos) {
          ans += get_cnt(s[col[r]].R, need);
        }
      }
      if (l < pos) {
        s[col[l]].L.clear();
        s[col[l]].R.clear();
      }
      for (int j = l; j <= pos; ++j) {
        col[j] = cur_col;
        s[cur_col].R.add(sum[j]);
        s[cur_col].L.add((j > 0 ? sum[j - 1] : 0));
      }
      s[cur_col].l = l;
      s[cur_col].r = r;
    } else {
      int cur_col;
      if (l < pos) {
        cur_col = col[l];
      } else {
        cur_col = ptr++;
      }
      for (int j = r; j >= pos; --j) {
        int need = sum[j] - (a[i].first % k);
        if (need < 0) {
          need += k;
        }
        if (j > pos && (pos > 0 ? sum[pos - 1] : 0) == need) {
          ++ans;
        }
        if (l < pos) {
          ans += get_cnt(s[col[l]].L, need);
        }
      }
      if (r > pos) {
        s[col[r]].L.clear();
        s[col[r]].R.clear();
      }
      for (int j = r; j >= pos; --j) {
        col[j] = cur_col;
        s[cur_col].R.add(sum[j]);
        s[cur_col].L.add((j > 0 ? sum[j - 1] : 0));
      }
      s[cur_col].l = l;
      s[cur_col].r = r;
    }
  }
  cout << ans << endl;
  return 0;
}
