#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 50;
int n, m, k, c[N];
vector<int> G[N];
vector<int> S[N];
vector<pair<int, int> > E[N];
map<pair<int, int>, int> mp;
int o[N], blk[N];
bool ban[N];
vector<int> H[N];
int A, B;
void dfs(int S, int u, int oc) {
  if (o[u] >= 0) {
    if (o[u] ^ oc) ban[S] = true;
    return;
  }
  o[u] = oc, blk[u] = oc ? B : A;
  for (int v : G[u])
    if (c[v] == S) dfs(S, v, oc ^ 1);
}
bool ok;
vector<int> clr;
void chk(int u, int oc) {
  if (o[u] >= 0) {
    if (o[u] ^ oc) ok = false;
    return;
  }
  if (!ok) return;
  clr.push_back(u), o[u] = oc;
  for (int v : H[u]) chk(v, oc ^ 1);
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]), S[c[i]].push_back(i);
  for (int i = 1, u, v; i <= m; i++) {
    scanf("%d%d", &u, &v);
    G[u].push_back(v), G[v].push_back(u);
  }
  int nd = n;
  memset(o, -1, sizeof(o));
  int _k = k;
  for (int i = 1; i <= k; i++) {
    for (int z : S[i])
      if (o[z] == -1)
        A = ++nd, B = ++nd, dfs(i, z, 0), H[A].push_back(B), H[B].push_back(A);
    if (ban[i]) --_k;
  }
  int ct = 0;
  for (int u = 1; u <= n; u++)
    if (!ban[c[u]])
      for (int v : G[u])
        if (!ban[c[v]] && c[u] < c[v]) {
          if (!mp.count(pair<int, int>(c[u], c[v])))
            mp[pair<int, int>(c[u], c[v])] = ++ct;
          int t = mp[pair<int, int>(c[u], c[v])];
          E[t].push_back(pair<int, int>(u, v));
        }
  long long ans = 1ll * _k * (_k - 1) / 2 - ct;
  memset(o, -1, sizeof(o));
  for (int i = 1; i <= ct; i++) {
    vector<int> T;
    for (pair<int, int> z : E[i]) {
      int u = blk[z.first], v = blk[z.second];
      H[u].push_back(v), H[v].push_back(u), T.push_back(u), T.push_back(v);
    }
    ok = true;
    for (int z : T)
      if (o[z] == -1) {
        chk(z, 0);
        if (!ok) break;
      }
    ans += ok;
    for (int z : clr) o[z] = -1;
    clr.clear();
    for (pair<int, int> z : E[i]) {
      int u = blk[z.first], v = blk[z.second];
      H[u].pop_back(), H[v].pop_back();
    }
  }
  cout << ans;
  return 0;
}
