#include <bits/stdc++.h>
using namespace std;
const int Maxn = 500010;
const int inf = 2147483647;
const double pi = acos(-1.0);
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 n, m, k, a[Maxn];
long long ans, rest;
bool del[Maxn];
struct Edge {
  int x, y;
} e[Maxn];
int fa[Maxn << 1], dep[Maxn << 1];
int findfa(int x) { return ((fa[x] == x) ? x : findfa(fa[x])); }
int top = 0, sta[Maxn << 1], o, fa1[Maxn << 1], dep1[Maxn << 1];
void merge(int x, int y) {
  int fx = findfa(x), fy = findfa(y);
  if (dep[fx] < dep[fy]) swap(fx, fy);
  sta[++top] = fy;
  fa1[top] = fa[fy], dep1[top] = dep[fx];
  fa[fy] = fx;
  dep[fx] = max(dep[fx], dep[fy] + 1);
}
void resume() {
  while (top > o) {
    int fy = sta[top];
    dep[fa[fy]] = dep1[top];
    fa[fy] = fa1[top];
    --top;
  }
}
vector<pair<int, int> > g[Maxn];
int tot = 0;
map<int, map<int, int> > mp;
int main() {
  memset(dep, 0, sizeof(dep));
  memset(del, false, sizeof(del));
  n = read(), m = read(), k = read();
  ans = (long long)k * (k - 1ll) / 2ll;
  rest = k - 1;
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= m; i++) e[i].x = read(), e[i].y = read();
  for (int i = 1; i <= n * 2; i++) fa[i] = i;
  for (int i = 1; i <= m; i++)
    if (!del[a[e[i].x]] && a[e[i].x] == a[e[i].y]) {
      int fx = findfa(e[i].x), fy = findfa(e[i].y);
      if (fx == fy)
        del[a[e[i].x]] = true, ans -= rest, rest--;
      else
        merge(e[i].x, e[i].y + n), merge(e[i].y, e[i].x + n);
    }
  o = top;
  for (int i = 1; i <= m; i++)
    if (a[e[i].x] != a[e[i].y] && !del[a[e[i].x]] && !del[a[e[i].y]]) {
      int cx = a[e[i].x], cy = a[e[i].y];
      if (cx > cy) swap(cx, cy);
      if (!mp[cx][cy]) mp[cx][cy] = ++tot;
      g[mp[cx][cy]].push_back(make_pair(e[i].x, e[i].y));
    }
  for (int i = 1; i <= tot; i++) {
    for (int j = 0; j < g[i].size(); j++) {
      int x = g[i][j].first, y = g[i][j].second;
      int fx = findfa(x), fy = findfa(y);
      if (fx == fy) {
        ans--;
        break;
      }
      merge(x, y + n);
      merge(y, x + n);
    }
    resume();
  }
  printf("%lld", ans);
}
