#include <bits/stdc++.h>
const int MAXN = 1000005;
int a[MAXN], seq[MAXN][2], max[MAXN];
int main() {
  int n, x;
  scanf("%d %d", &n, &x);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= x; i++) {
    seq[i][0] = n + 1;
    seq[i][1] = -1;
  }
  for (int i = 0; i < n; i++) {
    seq[a[i]][0] = std::min(seq[a[i]][0], i);
    seq[a[i]][1] = std::max(seq[a[i]][1], i);
  }
  seq[0][0] = seq[0][1] = -1;
  long long ans = 0;
  int l = -1;
  max[0] = -1, max[1] = seq[1][1];
  for (int i = 1; i < x; i++) {
    if (seq[i + 1][0] > max[i])
      max[i + 1] = std::max(max[i], seq[i + 1][1]);
    else {
      l = i;
      break;
    }
  }
  if (l == -1) {
    ans = 1ll * (x + 1) * x / 2;
  } else {
    int min = n + 1;
    for (int i = l, j = x; i >= 0; i--) {
      while (seq[j][0] > max[i] && seq[j][1] < min && i < j) {
        min = std::min(min, seq[j][0]);
        --j;
      }
      ans += x - j + 1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
