#include <bits/stdc++.h>
using namespace std;
vector<int> f(const vector<int>& a) {
  vector<int> d(301);
  for (int i = 0; i < a.size(); ++i) {
    vector<int> nd = d;
    for (int j = 0; j <= a[i]; ++j) {
      nd[a[i]] = max(nd[a[i]], d[j] + 1);
    }
    d.swap(nd);
  }
  return d;
}
vector<int> g(const vector<int>& a) {
  vector<int> d(301);
  for (int i = a.size() - 1; i >= 0; --i) {
    vector<int> nd = d;
    for (int j = a[i]; j < d.size(); ++j) {
      nd[a[i]] = max(nd[a[i]], d[j] + 1);
    }
    d.swap(nd);
  }
  return d;
}
int main() {
  int n, t;
  cin >> n >> t;
  vector<int> a(n);
  vector<int> c(301);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ++c[a[i]];
  }
  int X = 301;
  int it = min(t, X);
  for (int i = 0; i < it - 1; ++i)
    for (int j = 0; j < n; ++j) a.push_back(a[j]);
  vector<int> b = f(a);
  int it1 = min(X, t - it);
  a.resize(it1 * n);
  vector<int> d = g(a);
  long long ma = 0;
  int cur = 0;
  for (int i = 0; i < c.size(); ++i) {
    cur = max(cur, b[i]);
    int m1 = 0;
    for (int j = i; j < d.size(); ++j) m1 = max(m1, d[j]);
    ma = max(ma, m1 + cur + (t - it - it1) * (long long)c[i]);
  }
  cout << ma << endl;
  return 0;
}

### Prompt

Please formulate 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;
vector<int> f(const vector<int>& a) {
  vector<int> d(301);
  for (int i = 0; i < a.size(); ++i) {
    vector<int> nd = d;
    for (int j = 0; j <= a[i]; ++j) {
      nd[a[i]] = max(nd[a[i]], d[j] + 1);
    }
    d.swap(nd);
  }
  return d;
}
vector<int> g(const vector<int>& a) {
  vector<int> d(301);
  for (int i = a.size() - 1; i >= 0; --i) {
    vector<int> nd = d;
    for (int j = a[i]; j < d.size(); ++j) {
      nd[a[i]] = max(nd[a[i]], d[j] + 1);
    }
    d.swap(nd);
  }
  return d;
}
int main() {
  int n, t;
  cin >> n >> t;
  vector<int> a(n);
  vector<int> c(301);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ++c[a[i]];
  }
  int X = 301;
  int it = min(t, X);
  for (int i = 0; i < it - 1; ++i)
    for (int j = 0; j < n; ++j) a.push_back(a[j]);
  vector<int> b = f(a);
  int it1 = min(X, t - it);
  a.resize(it1 * n);
  vector<int> d = g(a);
  long long ma = 0;
  int cur = 0;
  for (int i = 0; i < c.size(); ++i) {
    cur = max(cur, b[i]);
    int m1 = 0;
    for (int j = i; j < d.size(); ++j) m1 = max(m1, d[j]);
    ma = max(ma, m1 + cur + (t - it - it1) * (long long)c[i]);
  }
  cout << ma << endl;
  return 0;
}

```