#include <bits/stdc++.h>
using namespace std;
pair<int, int> e[105], ar[105 * 105];
int n, m, t, i, j, k, a, b, c, d[105], tut, syc, res, pre[105][105],
    suf[105][105], cnt[105], syc2, syc3;
int main() {
  scanf("%d %d", &n, &t);
  for (i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
    e[i] = make_pair(d[i], i);
  }
  sort(e + 1, e + n + 1);
  tut = -1;
  for (i = 1; i <= n; i++) {
    if (e[i].first != tut) {
      tut = e[i].first;
      ++syc;
    }
    d[e[i].second] = syc;
  }
  for (i = 1; i <= n; i++) cnt[d[i]] += 1;
  for (j = 1; j <= n; j++) {
    for (i = 1; i <= n; i++) {
      ++syc3;
      if (syc2 == 0) {
        ar[++syc2] = make_pair(d[i], syc3);
        continue;
      }
      if (ar[syc2].first <= d[i]) {
        ar[++syc2] = make_pair(d[i], syc3);
        continue;
      }
      int id = upper_bound(ar + 1, ar + syc2, make_pair(d[i] + 1, -1)) - ar;
      ar[id] = make_pair(d[i], syc3);
    }
    for (i = syc2; i; i--) {
      if (ar[i].second <= (j - 1) * n) break;
      pre[j][ar[i].first] = max(i, pre[j][ar[i].first]);
    }
    for (i = 1; i <= n; i++) pre[j][i] = max(pre[j][i - 1], pre[j][i]);
  }
  syc3 = 0, syc2 = 0;
  for (j = 1; j <= n; j++) {
    for (i = n; i; i--) {
      ++syc3;
      if (syc2 == 0) {
        ar[++syc2] = make_pair(-d[i], syc3);
        continue;
      }
      if (ar[syc2].first <= -d[i]) {
        ar[++syc2] = make_pair(-d[i], syc3);
        continue;
      }
      int id = upper_bound(ar + 1, ar + syc2, make_pair(-d[i] + 1, -1)) - ar;
      ar[id] = make_pair(-d[i], syc3);
    }
    for (i = syc2; i; i--) {
      if (ar[i].second <= (j - 1) * n) break;
      ar[i].first *= -1;
      suf[j][ar[i].first] = max(suf[j][ar[i].first], i);
      ar[i].first *= -1;
    }
    for (i = n; i; i--) suf[j][i] = max(suf[j][i + 1], suf[j][i]);
  }
  for (i = 1; i <= syc; i++) {
    for (j = 0; j <= n; j++) {
      for (k = 0; k <= n; k++) {
        if (k + j > t) continue;
        res = max(res, (t - j - k) * cnt[i] + pre[j][i] + suf[k][i]);
      }
    }
  }
  cout << res << endl;
  return 0;
}

### Prompt

Your challenge is to write a cpp solution to the following problem:

You are given an array of positive integers a1, a2, ..., an × T of length n × T. We know that for any i > n it is true that ai = ai - n. Find the length of the longest non-decreasing sequence of the given array.

Input

The first line contains two space-separated integers: n, T (1 ≤ n ≤ 100, 1 ≤ T ≤ 107). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 300).

Output

Print a single number — the length of a sought sequence.

Examples

Input

4 3
3 1 4 2


Output

5

Note

The array given in the sample looks like that: 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2. The elements in bold form the largest non-decreasing subsequence. 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
pair<int, int> e[105], ar[105 * 105];
int n, m, t, i, j, k, a, b, c, d[105], tut, syc, res, pre[105][105],
    suf[105][105], cnt[105], syc2, syc3;
int main() {
  scanf("%d %d", &n, &t);
  for (i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
    e[i] = make_pair(d[i], i);
  }
  sort(e + 1, e + n + 1);
  tut = -1;
  for (i = 1; i <= n; i++) {
    if (e[i].first != tut) {
      tut = e[i].first;
      ++syc;
    }
    d[e[i].second] = syc;
  }
  for (i = 1; i <= n; i++) cnt[d[i]] += 1;
  for (j = 1; j <= n; j++) {
    for (i = 1; i <= n; i++) {
      ++syc3;
      if (syc2 == 0) {
        ar[++syc2] = make_pair(d[i], syc3);
        continue;
      }
      if (ar[syc2].first <= d[i]) {
        ar[++syc2] = make_pair(d[i], syc3);
        continue;
      }
      int id = upper_bound(ar + 1, ar + syc2, make_pair(d[i] + 1, -1)) - ar;
      ar[id] = make_pair(d[i], syc3);
    }
    for (i = syc2; i; i--) {
      if (ar[i].second <= (j - 1) * n) break;
      pre[j][ar[i].first] = max(i, pre[j][ar[i].first]);
    }
    for (i = 1; i <= n; i++) pre[j][i] = max(pre[j][i - 1], pre[j][i]);
  }
  syc3 = 0, syc2 = 0;
  for (j = 1; j <= n; j++) {
    for (i = n; i; i--) {
      ++syc3;
      if (syc2 == 0) {
        ar[++syc2] = make_pair(-d[i], syc3);
        continue;
      }
      if (ar[syc2].first <= -d[i]) {
        ar[++syc2] = make_pair(-d[i], syc3);
        continue;
      }
      int id = upper_bound(ar + 1, ar + syc2, make_pair(-d[i] + 1, -1)) - ar;
      ar[id] = make_pair(-d[i], syc3);
    }
    for (i = syc2; i; i--) {
      if (ar[i].second <= (j - 1) * n) break;
      ar[i].first *= -1;
      suf[j][ar[i].first] = max(suf[j][ar[i].first], i);
      ar[i].first *= -1;
    }
    for (i = n; i; i--) suf[j][i] = max(suf[j][i + 1], suf[j][i]);
  }
  for (i = 1; i <= syc; i++) {
    for (j = 0; j <= n; j++) {
      for (k = 0; k <= n; k++) {
        if (k + j > t) continue;
        res = max(res, (t - j - k) * cnt[i] + pre[j][i] + suf[k][i]);
      }
    }
  }
  cout << res << endl;
  return 0;
}

```