#include <bits/stdc++.h>
using namespace std;
vector<int> adj[500000];
vector<pair<int, int>> B;
vector<tuple<int, int, int, int>> EE;
pair<int, int> E[500000];
int chk[500000], color[500000], cnt[500000], G[500000], R[500000];
bool valid[500000];
void dfs(int c, int v) {
  chk[c] = v;
  for (auto n : adj[c]) {
    if (chk[n] == -1)
      dfs(n, v ^ 1);
    else if (chk[c] == chk[n])
      valid[G[c]] = false;
  }
}
int find_(int a) {
  while (color[a] != a) a = color[a];
  return a;
}
int get_color(int a) {
  int ret = chk[a];
  for (; a != color[a]; a = color[a]) ret ^= R[a];
  return ret ^ R[a];
}
void union_(int a, int b) {
  int ta = a, taa, tb = b, tbb;
  a = find_(a);
  b = find_(b);
  if (a == b) return;
  taa = get_color(ta);
  tbb = get_color(tb);
  if (cnt[a] < cnt[b]) swap(a, b);
  color[b] = a;
  cnt[a] += cnt[b];
  if (taa == tbb) R[b] ^= 1;
  B.emplace_back(b, taa == tbb);
}
void restore() {
  while (B.size()) {
    auto [c, v] = B.back();
    B.pop_back();
    cnt[color[c]] -= cnt[c];
    color[c] = c;
    if (v) R[c] ^= 1;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ((void)0);
  ((void)0);
  ((void)0);
  int N, M, K, pa = -1, pb = -1;
  long long ans = 0;
  bool vvv = true;
  cin >> N >> M >> K;
  memset(chk, -1, sizeof(chk));
  for (int i = 0; i < K; i++) valid[i] = true;
  for (int i = 0; i < N; i++) {
    cin >> G[i];
    G[i]--;
    cnt[color[i] = i] = 1;
  }
  for (int i = 0; i < M; i++) {
    cin >> E[i].first >> E[i].second;
    if (G[--E[i].first] == G[--E[i].second]) {
      adj[E[i].first].push_back(E[i].second);
      adj[E[i].second].push_back(E[i].first);
    }
  }
  for (int i = 0; i < N; i++)
    if (chk[i] == -1) dfs(i, 0);
  for (int i = 0; i < K; i++) ans += valid[i];
  ans = ans * (ans - 1) / 2;
  for (int i = 0; i < M; i++) {
    if (G[E[i].first] == G[E[i].second])
      union_(E[i].first, E[i].second);
    else if (valid[G[E[i].first]] && valid[G[E[i].second]]) {
      int ga = G[E[i].first], gb = G[E[i].second];
      if (ga > gb) swap(ga, gb);
      EE.emplace_back(ga, gb, E[i].first, E[i].second);
    }
  }
  B.clear();
  sort(EE.begin(), EE.end());
  for (auto [a, b, u, v] : EE) {
    if (a != pa || b != pb) {
      pa = a;
      pb = b;
      restore();
      vvv = true;
    }
    if (!vvv) continue;
    if (find_(u) != find_(v))
      union_(u, v);
    else if (get_color(u) == get_color(v)) {
      vvv = false;
      ans--;
    }
  }
  cout << ans << '\n';
  return 0;
}
