#include <bits/stdc++.h>
using namespace std;
int n, t, a[10000], cnt[301], prv[301], ans;
int solve(int t, int m) {
  for (int i = 1; i <= 300; ++i) prv[i] = 0;
  for (int i = 0; i < n * min(n, t); ++i) {
    if (a[i] > m) continue;
    int x = 1;
    for (int j = a[i]; j; --j) x = max(x, prv[j] + 1);
    prv[a[i]] = max(x, prv[a[i]]);
  }
  int ans1 = 0;
  for (int i = 1; i <= 300; ++i) ans1 = max(ans1, prv[i]);
  t -= n;
  if (t <= 0) return ans1;
  for (int i = 1; i <= 300; ++i) prv[i] = 0;
  for (int i = 0; i < n * min(n, t); ++i) {
    if (a[i] < m) continue;
    int x = 1;
    for (int j = a[i]; j; --j) x = max(x, prv[j] + 1);
    prv[a[i]] = max(x, prv[a[i]]);
  }
  int ans2 = 0;
  for (int i = 1; i <= 300; ++i) ans2 = max(ans2, prv[i]);
  t -= n;
  if (t <= 0) return ans1 + ans2;
  return ans1 + ans2 + t * cnt[m];
}
int main() {
  cin >> n >> t;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ++cnt[a[i]];
  }
  for (int i = n; i < n * n; ++i) a[i] = a[i - n];
  for (int i = 1; i <= 300; ++i)
    if (cnt[i]) ans = max(ans, solve(t, i));
  cout << ans << endl;
  return 0;
}
