#include <bits/stdc++.h>
using namespace std;
const int maxn = 300 + 5;
const int INF = 1 << 30;
int a[maxn * maxn], num[maxn], d1[maxn * maxn], d2[maxn * maxn], m[maxn * maxn];
int C(int l, int r, int x) {
  while (l < r) {
    int mid = (l + r) >> 1;
    m[mid] >= x ? l = mid + 1 : r = mid;
  }
  return l;
}
int main() {
  int n, t;
  while (~scanf("%d%d", &n, &t)) {
    memset(num, 0, sizeof(num));
    for (int i = 1; i <= n; ++i) {
      scanf("%d", a + i);
      ++num[a[i]];
    }
    long long ans = 0;
    for (int k = 1; k <= min(n, t); ++k) {
      for (int i = 1; i <= n; ++i) {
        a[i + (k - 1) * n] = a[i];
      }
      int e = k * n + 1;
      memset(d1, 0, sizeof(d1));
      memset(d2, 0, sizeof(d2));
      m[0] = 0;
      int len = 0;
      for (int i = 1; i < e; ++i) {
        int l = upper_bound(m, m + len + 1, a[i]) - m;
        d1[i] = l;
        m[l] = a[i];
        len = max(l, len);
      }
      m[0] = INF;
      len = 0;
      for (int i = e - 1; i; --i) {
        int l = C(0, len + 1, a[i]);
        d2[i] = l;
        m[l] = a[i];
        len = max(l, len);
      }
      for (int i = 1; i < e; ++i) {
        ans = max(ans, (long long)(d1[i] + d2[i] - 1) +
                           (long long)(t - k) * num[a[i]]);
      }
    }
    printf("%I64d\n", ans);
  }
  return 0;
}

### Prompt

Your task is to create 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;
const int maxn = 300 + 5;
const int INF = 1 << 30;
int a[maxn * maxn], num[maxn], d1[maxn * maxn], d2[maxn * maxn], m[maxn * maxn];
int C(int l, int r, int x) {
  while (l < r) {
    int mid = (l + r) >> 1;
    m[mid] >= x ? l = mid + 1 : r = mid;
  }
  return l;
}
int main() {
  int n, t;
  while (~scanf("%d%d", &n, &t)) {
    memset(num, 0, sizeof(num));
    for (int i = 1; i <= n; ++i) {
      scanf("%d", a + i);
      ++num[a[i]];
    }
    long long ans = 0;
    for (int k = 1; k <= min(n, t); ++k) {
      for (int i = 1; i <= n; ++i) {
        a[i + (k - 1) * n] = a[i];
      }
      int e = k * n + 1;
      memset(d1, 0, sizeof(d1));
      memset(d2, 0, sizeof(d2));
      m[0] = 0;
      int len = 0;
      for (int i = 1; i < e; ++i) {
        int l = upper_bound(m, m + len + 1, a[i]) - m;
        d1[i] = l;
        m[l] = a[i];
        len = max(l, len);
      }
      m[0] = INF;
      len = 0;
      for (int i = e - 1; i; --i) {
        int l = C(0, len + 1, a[i]);
        d2[i] = l;
        m[l] = a[i];
        len = max(l, len);
      }
      for (int i = 1; i < e; ++i) {
        ans = max(ans, (long long)(d1[i] + d2[i] - 1) +
                           (long long)(t - k) * num[a[i]]);
      }
    }
    printf("%I64d\n", ans);
  }
  return 0;
}

```