#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
const int INF = 1e9;
int arr[maxn];
int main() {
  int n, x;
  scanf("%d %d", &n, &x);
  vector<int> leftmost(x + 1, INF);
  vector<int> rightmost(x + 1, -1);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    leftmost[arr[i]] = min(leftmost[arr[i]], i);
    rightmost[arr[i]] = max(rightmost[arr[i]], i);
  }
  bool ck = 0;
  for (int i = 1; i < n; i++) {
    if (!(arr[i] <= arr[i + 1])) {
      ck = 1;
      break;
    }
  }
  if (ck == 0) {
    printf("%lld\n", (1LL * x * (x + 1)) / 2);
    return 0;
  }
  vector<int> left, right;
  int L = 1;
  int tmp = rightmost[L];
  left.push_back(-1);
  left.push_back(tmp);
  while (tmp < leftmost[L + 1]) {
    tmp = max(tmp, rightmost[L + 1]);
    L++;
    left.push_back(tmp);
  }
  int R = x;
  tmp = leftmost[R];
  right.push_back(INF);
  right.push_back(tmp);
  while (tmp > rightmost[R - 1]) {
    tmp = min(tmp, leftmost[R - 1]);
    R--;
    right.push_back(tmp);
  }
  long long ans = 0;
  int index = right.size() - 1;
  for (int x : left) {
    while (index >= 0 && right[index] < x) {
      index--;
    }
    ans += index + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
