#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 20;
long long n, m, k;
long long col[N];
vector<long long> g[N];
struct edge {
  long long u, v;
} e[N];
long long ans;
long long dead[N];
map<pair<long long, long long>, bool> vis;
map<pair<long long, long long>, vector<pair<long long, long long>>>
    edges_between;
long long par[N], f[N];
vector<pair<long long, long long>> parhistory, fhistory;
long long root(long long v, bool save_history = 0) {
  if (par[v] < 0) return v;
  if (save_history) {
    parhistory.push_back({v, par[v]});
    fhistory.push_back({v, f[v]});
  }
  long long res = root(par[v], save_history);
  f[v] ^= f[par[v]];
  par[v] = res;
  return res;
}
inline long long merge(long long u, long long v, bool save_history = 0) {
  long long ru = root(u, save_history), rv = root(v, save_history);
  if (ru == rv) {
    if (f[u] == f[v]) return -1;
    return 0;
  }
  if (save_history) {
    parhistory.push_back({ru, -1});
    fhistory.push_back({ru, 0});
  }
  if (f[u] == f[v])
    f[ru] = 1;
  else
    f[ru] = 0;
  par[ru] = rv;
  return 1;
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> k;
  for (long long i = 0; i < n; i++) cin >> col[i], col[i]--;
  for (long long i = 0; i < m; i++) {
    cin >> e[i].u >> e[i].v;
    e[i].u--, e[i].v--;
    g[e[i].u].push_back(e[i].v);
    g[e[i].v].push_back(e[i].u);
  }
  memset(par, -1, sizeof par);
  for (long long i = 0; i < m; i++) {
    long long u = e[i].u, v = e[i].v;
    if (col[u] == col[v]) {
      if (merge(u, v) == -1) dead[col[u]] = 1;
    }
  }
  long long cnt = 0;
  for (long long i = 0; i < k; i++) cnt += (!dead[i]);
  for (long long i = 0; i < n; i++) root(i);
  ans = 1ll * cnt * (cnt - 1) / 2;
  for (long long i = 0; i < m; i++) {
    long long u = e[i].u, v = e[i].v;
    if (col[u] == col[v]) continue;
    if (dead[col[u]] || dead[col[v]]) continue;
    long long x = col[u], y = col[v];
    if (x > y) swap(x, y);
    edges_between[{x, y}].push_back({u, v});
    vis[{x, y}] = 1;
  }
  for (auto p : vis) {
    long long x = p.first.first, y = p.first.second;
    ans--;
    bool ok = 1;
    for (pair<long long, long long> ed : edges_between[{x, y}]) {
      if (merge(ed.first, ed.second, 1) == -1) {
        ok = 0;
        break;
      }
    }
    while (parhistory.size()) {
      pair<long long, long long> p = parhistory.back();
      par[p.first] = p.second;
      parhistory.pop_back();
    }
    while (fhistory.size()) {
      pair<long long, long long> p = fhistory.back();
      f[p.first] = p.second;
      fhistory.pop_back();
    }
    ans += ok;
  }
  cout << ans << '\n';
}
