#include <bits/stdc++.h>
using namespace std;
const int Maxn = 5e5 + 5;
int n, m, k, a[Maxn], fath[Maxn], dis[Maxn], cnt;
char rnk[Maxn], Fail[Maxn];
pair<int, int> tag[Maxn];
map<pair<int, int>, int> ht;
vector<pair<int, int> > co[Maxn];
pair<int, char> sta[Maxn];
int top;
long long ans;
inline int Find(int x, int &res) {
  res = 0;
  while (x != fath[x]) {
    res ^= dis[x];
    x = fath[x];
  }
  return x;
}
inline bool Merge(int a, int b) {
  int da, db;
  int x = Find(a, da), y = Find(b, db);
  if (x == y) return da ^ db;
  if (rnk[x] > rnk[y]) swap(x, y);
  sta[top++] = make_pair(x, rnk[y]);
  rnk[y] += (rnk[x] == rnk[y]);
  fath[x] = y;
  dis[x] = da ^ db ^ 1;
  return 1;
}
inline void back(int t) {
  while (top > t) {
    int x = sta[--top].first;
    rnk[fath[x]] = sta[top].second;
    fath[x] = x;
    dis[x] = 0;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    fath[i] = i;
  }
  for (int i = 1, u, v; i <= m; ++i) {
    scanf("%d%d", &u, &v);
    if (a[v] < a[u]) swap(u, v);
    if (!ht.count(make_pair(a[u], a[v]))) {
      ht[make_pair(a[u], a[v])] = ++cnt;
      tag[cnt] = make_pair(a[u], a[v]);
    }
    int t = ht[make_pair(a[u], a[v])];
    co[t].emplace_back(u, v);
    if (a[u] == a[v] && !Fail[a[u]] && !Merge(u, v)) {
      Fail[a[u]] = 1;
      --k;
    }
  }
  if (k < 2) {
    printf("0\n");
    return 0;
  }
  ans = (k - 1ll) * k / 2;
  for (int i = 1; i <= cnt; ++i) {
    if (Fail[tag[i].first] || Fail[tag[i].second]) continue;
    int Tm = top;
    for (pair<int, int> &edge : co[i])
      if (!Merge(edge.first, edge.second)) {
        ans--;
        break;
      }
    back(Tm);
  }
  printf("%lld\n", ans);
  return 0;
}
