#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll mod = 1E9;
const int inf = 2E9;
vector<int> LisNlogK(int n, vector<int>& Sequence) {
  vector<int> I(n + 1, inf), ans(n, 0);
  I[0] = -inf;
  int LisLength = 0;
  for (int i = 0; i < n; i++) {
    int low, high, mid;
    low = 0;
    high = LisLength;
    while (low <= high) {
      mid = (low + high) / 2;
      if (I[mid] <= Sequence[i])
        low = mid + 1;
      else
        high = mid - 1;
    }
    I[low] = Sequence[i];
    if (LisLength < low) LisLength = low;
    ans[i] = low;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  int n, t;
  cin >> n >> t;
  vector<int> tmp(n), a, cnt(310, 0);
  for (int i = 0; i < n; i++) {
    cin >> tmp[i];
    cnt[tmp[i]]++;
  }
  for (int i = 0; i < n; i++) {
    a.insert(a.end(), tmp.begin(), tmp.end());
  }
  vector<int> b = a;
  reverse(b.begin(), b.end());
  for (int i = 0; i < n * n; i++) {
    b[i] = -b[i];
  }
  if (t <= 2 * n) {
    a.insert(a.end(), a.begin(), a.end());
    vector<int> LISa = LisNlogK(2 * n * n, a);
    cout << *max_element(LISa.begin(), LISa.begin() + (t * n)) << endl;
  } else {
    vector<int> LISa = LisNlogK(n * n, a);
    vector<int> LISb = LisNlogK(n * n, b);
    reverse(LISb.begin(), LISb.end());
    int ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++)
        if (a[j] >= a[i]) {
          for (int k = 0; k < n; k++)
            if (a[k] >= a[i] && a[k] <= a[j]) {
              ans = max(ans, LISa[n * (min(n, t) - 1) + i] +
                                 (t - 2 * min(n, t)) * cnt[a[k]] + LISb[j]);
            }
        }
    }
    cout << ans << endl;
  }
  return 0;
}
