#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
int fp[maxn], ep[maxn];
int L[maxn], R[maxn];
bool book[2][maxn];
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int main(int argc, char *argv[]) {
  int n, x;
  int t;
  int lt, rt;
  long long ans = 0;
  n = read();
  x = read();
  for (int i = 1; i <= n; i++) {
    t = read();
    if (fp[t] == 0) fp[t] = i;
    ep[t] = i;
  }
  fp[0] = ep[0] = 0;
  fp[x + 1] = ep[x + 1] = n + 1;
  for (lt = 1; lt <= x; lt++)
    if (fp[lt] && R[lt - 1] > fp[lt]) {
      lt = lt - 1;
      break;
    } else
      R[lt] = max(R[lt - 1], ep[lt]);
  if (lt == x + 1) {
    ans = 1ll * (x + 1) * x / 2;
  } else {
    L[x + 1] = n + 1;
    rt = x + 1;
    for (int i = x; i >= 1; i--) {
      if (L[i + 1] < ep[i]) {
        ans += 1ll * (lt + 1) * (x - i + 1);
        lt = -1;
      } else {
        L[i] = fp[i] == 0 ? L[i + 1] : fp[i];
        while (lt != -1 && ep[i] && R[lt] > L[i]) {
          ans += (x - i + 1);
          lt--;
        }
      }
      if (lt == -1) break;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
