#include <bits/stdc++.h>
double eps = 1e-10;
using namespace std;
int n, mx;
long long t;
int cnt[305], dp[100005], DP[100005], starts[305], End[305], a[200005];
int main() {
  cin >> n >> t;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
    for (int j = 1; j < 2 * n; j++) a[j * n + i] = a[i];
  }
  if (t < 2 * n) {
    long long ans = 0;
    for (int i = 1; i <= t * n; i++) {
      for (int j = i - 1; j >= 1; j--) {
        if (a[i] >= a[j]) dp[i] = max(dp[i], dp[j]);
      }
      dp[i]++;
      ans = (ans > dp[i] ? ans : dp[i]);
    }
    cout << ans << endl;
    return 0;
  }
  for (int i = 1; i <= n * n; i++) {
    for (int j = i - 1; j >= 1; j--) {
      if (a[i] >= a[j]) dp[i] = max(dp[i], dp[j]);
    }
    dp[i]++;
    End[a[i]] = (End[a[i]] > dp[i] ? End[a[i]] : dp[i]);
  }
  for (int i = n * n; i >= 1; i--) {
    for (int j = i + 1; j <= n * n; j++) {
      if (a[j] >= a[i]) DP[i] = max(DP[i], DP[j]);
    }
    DP[i]++;
    starts[a[i]] = (starts[a[i]] > DP[i] ? starts[a[i]] : DP[i]);
  }
  for (int i = 1; i <= 300; i++) End[i] = max(End[i], End[i - 1]);
  for (int i = 300; i >= 1; i--) starts[i] = max(starts[i], starts[i + 1]);
  long long ans = 0;
  for (int k = 1; k <= 300; k++) {
    long long c = cnt[k];
    long long x = End[k];
    long long y = starts[k];
    ans = (ans > x + y + (t - 2 * n) * c ? ans : x + y + (t - 2 * n) * c);
  }
  cout << ans << endl;
}

### Prompt

Construct a CPP code solution to the problem outlined:

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>
double eps = 1e-10;
using namespace std;
int n, mx;
long long t;
int cnt[305], dp[100005], DP[100005], starts[305], End[305], a[200005];
int main() {
  cin >> n >> t;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
    for (int j = 1; j < 2 * n; j++) a[j * n + i] = a[i];
  }
  if (t < 2 * n) {
    long long ans = 0;
    for (int i = 1; i <= t * n; i++) {
      for (int j = i - 1; j >= 1; j--) {
        if (a[i] >= a[j]) dp[i] = max(dp[i], dp[j]);
      }
      dp[i]++;
      ans = (ans > dp[i] ? ans : dp[i]);
    }
    cout << ans << endl;
    return 0;
  }
  for (int i = 1; i <= n * n; i++) {
    for (int j = i - 1; j >= 1; j--) {
      if (a[i] >= a[j]) dp[i] = max(dp[i], dp[j]);
    }
    dp[i]++;
    End[a[i]] = (End[a[i]] > dp[i] ? End[a[i]] : dp[i]);
  }
  for (int i = n * n; i >= 1; i--) {
    for (int j = i + 1; j <= n * n; j++) {
      if (a[j] >= a[i]) DP[i] = max(DP[i], DP[j]);
    }
    DP[i]++;
    starts[a[i]] = (starts[a[i]] > DP[i] ? starts[a[i]] : DP[i]);
  }
  for (int i = 1; i <= 300; i++) End[i] = max(End[i], End[i - 1]);
  for (int i = 300; i >= 1; i--) starts[i] = max(starts[i], starts[i + 1]);
  long long ans = 0;
  for (int k = 1; k <= 300; k++) {
    long long c = cnt[k];
    long long x = End[k];
    long long y = starts[k];
    ans = (ans > x + y + (t - 2 * n) * c ? ans : x + y + (t - 2 * n) * c);
  }
  cout << ans << endl;
}

```