#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int e[N][2], c[N], fa[N], w[N], s[N], z[N], n, m, K;
struct eg {
  int x, y;
  eg(int x_ = 0, int y_ = 0) {
    x = x_, y = y_;
    if (c[x] > c[y]) swap(x, y);
  }
  bool operator<(const eg& b) const {
    return c[x] == c[b.x] ? c[y] < c[b.y] : c[x] < c[b.x];
  }
} a[N];
bool del[N];
long long ans;
void In(int& a) {
  a = 0;
  char c = getchar();
  for (; c < 48 || c > 57; c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) a = (a << 1) + (a << 3) + c - 48;
}
int get(int x, int& r) {
  r = 0;
  while (x != fa[x]) r ^= w[x], x = fa[x];
  return x;
}
inline int add(int u, int v, int id) {
  static int fu, fv, cu, cv;
  fu = get(u, cu), fv = get(v, cv);
  if (fu != fv) {
    if (s[fu] > s[fv]) swap(fu, fv), swap(cu, cv);
    fa[fu] = fv, w[fu] = 1 ^ cv ^ cu, s[fv] += s[fu];
    z[id] = fu;
  } else if (cu == cv)
    return 1;
  return 0;
}
int main() {
  int u, v, dm, tm = 0, l, r, cur, js = 0;
  In(n), In(dm), In(K);
  ans = 1ll * K * (K - 1) / 2;
  for (int i = (1), _e = (n); i <= _e; i++) In(c[i]);
  for (int i = (1), _e = (n); i <= _e; i++) fa[i] = i, w[i] = 0, s[i] = 1;
  for (int i = (1), _e = (dm); i <= _e; i++) {
    In(u), In(v);
    if (c[u] == c[v]) {
      if (del[c[u]]) continue;
      if (add(u, v, 0)) del[c[u]] = true;
    } else
      e[++tm][0] = u, e[tm][1] = v;
  }
  for (int i = (1), _e = (K); i <= _e; i++)
    if (del[i]) ans -= K - 1, ++js;
  ans += 1ll * js * (js - 1) / 2;
  for (int i = (1), _e = (tm); i <= _e; i++)
    if (!del[c[e[i][0]]] && !del[c[e[i][1]]]) a[++m] = eg(e[i][0], e[i][1]);
  sort(a + 1, a + m + 1);
  for (l = 1; l <= m; l = r + 1) {
    for (r = l;
         r < m && c[a[r + 1].x] == c[a[l].x] && c[a[r + 1].y] == c[a[l].y]; r++)
      ;
    for (cur = l; cur <= r; cur++)
      if (add(a[cur].x, a[cur].y, cur)) break;
    if (cur <= r) ans--;
    for (cur--; cur >= l; cur--)
      if (z[cur]) {
        u = z[cur], v = fa[u];
        s[v] -= s[u], w[u] = 0, fa[u] = u;
        z[cur] = 0;
      }
  }
  printf("%lld", ans);
  return 0;
}
