#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
vector<long long int> edges[500010];
long long int c[500010], cc[500010], color[500010], bip[500010];
long long int dfs(long long int u, long long int co, long long int j) {
  color[u] = co;
  cc[u] = j;
  for (auto v : edges[u]) {
    if (c[v] != c[u]) continue;
    if (color[v] == color[u]) return false;
    if (color[v] != 0) continue;
    if (!dfs(v, 3 - co, j)) return false;
  }
  return true;
}
map<pair<long long int, long long int>,
    vector<pair<long long int, long long int>>>
    es;
map<long long int, vector<pair<long long int, long long int>>> gr;
map<long long int, long long int> flip;
long long int dfs2(long long int u, long long int f) {
  flip[u] = f;
  for (auto e : gr[u]) {
    long long int v = e.first;
    if (e.second == 0) {
      if (flip.count(v) && flip[v] != flip[u]) return false;
      if (flip.count(v) == 0) {
        if (!dfs2(v, f)) return false;
      }
    }
    if (e.second == 1) {
      if (flip.count(v) && flip[v] == flip[u]) return false;
      if (flip.count(v) == 0) {
        if (!dfs2(v, !f)) return false;
      }
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m, k;
  cin >> n >> m >> k;
  for (long long int i = 1; i <= n; ++i) cin >> c[i];
  for (long long int i = 0; i < m; ++i) {
    long long int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    edges[b].push_back(a);
    if (c[a] != c[b]) {
      long long int mi = min(c[a], c[b]);
      long long int ma = max(c[a], c[b]);
      es[{mi, ma}].push_back({a, b});
    }
  }
  for (long long int i = 1; i <= k; ++i) bip[i] = 1;
  for (long long int i = 1; i <= n; ++i) {
    if (!color[i]) {
      if (!dfs(i, 1, i)) bip[c[i]] = 0;
    }
  }
  long long int nb = accumulate(bip, bip + k + 1, 0ll);
  set<pair<long long int, long long int>> bad;
  for (auto pp : es) {
    long long int c1 = pp.first.first;
    long long int c2 = pp.first.second;
    if ((!bip[c1]) || (!bip[c2])) continue;
    gr.clear();
    flip.clear();
    set<long long int> rc;
    for (auto e : pp.second) {
      if (color[e.first] == color[e.second])
        gr[cc[e.first]].push_back({cc[e.second], 1});
      if (color[e.first] != color[e.second])
        gr[cc[e.first]].push_back({cc[e.second], 0});
      if (color[e.first] == color[e.second])
        gr[cc[e.second]].push_back({cc[e.first], 1});
      if (color[e.first] != color[e.second])
        gr[cc[e.second]].push_back({cc[e.first], 0});
      rc.insert(cc[e.first]);
      rc.insert(cc[e.second]);
    }
    for (auto i : rc) {
      if (!flip.count(i)) {
        if (!dfs2(i, 0)) bad.insert(pp.first);
      }
    }
  }
  cout << nb * (nb - 1) / 2 - bad.size() << endl;
}
