#include <bits/stdc++.h>
using std::max;
using std::min;
int l[1000010], ll[1000010], r[1000010], rr[1000010];
int main() {
  int n, x, a;
  scanf("%d %d", &n, &x);
  memset(l, 0x3f3f3f3f, sizeof(l)), memset(ll, 0x3f3f3f3f, sizeof(ll));
  for (int i = 1; i <= n; i++) scanf("%d", &a), l[a] = min(i, l[a]), r[a] = i;
  for (int i = 1; i <= x; i++) {
    rr[i] = max(rr[i - 1], r[i]);
    ll[x - i + 1] = min(l[x - i + 1], ll[x - i + 2]);
  }
  int R = x;
  long long ans = 0;
  while (ll[R] >= r[R - 1] && R >= 1) R--;
  for (int i = 0; i < x; i++) {
    if (i && l[i] < rr[i - 1]) break;
    while (R <= i + 1 || rr[i] > ll[R]) R++;
    ans += x - R + 2;
  }
  printf("%lld\n", ans);
}
