#include <bits/stdc++.h>
using namespace std;
int n, m, K;
int a[1000010];
int c[1000010];
int grp[1000010], gcnt;
bool chk[1000010];
vector<int> g[1000010];
int op(int u) { return u % 2 ? u + 1 : u - 1; }
void add(int u, int v) {
  g[u].push_back(v);
  g[v].push_back(u);
}
bool dfs(int u, int col, bool f) {
  if (c[u]) {
    if (c[u] != col) return false;
    return true;
  }
  c[u] = col;
  grp[u] = gcnt + col;
  for (auto& v : g[u]) {
    if (f && a[v] != a[u]) continue;
    if (!dfs(v, 3 - col, f)) return false;
  }
  return true;
}
int main() {
  int i, j, k;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> K;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    add(u, v);
  }
  int r = K;
  for (i = 1; i <= n; i++) {
    if (!c[i]) {
      if (!dfs(i, 1, true)) chk[a[i]] = true;
      gcnt += 2;
    }
  }
  for (i = 1; i <= K; i++)
    if (chk[i]) r--;
  vector<pair<pair<int, int>, pair<int, int>>> edges;
  for (i = 1; i <= n; i++) {
    for (auto& v : g[i]) {
      if (chk[a[i]] || chk[a[v]]) continue;
      if (a[i] != a[v] && a[i] < a[v]) {
        edges.push_back({{a[i], a[v]}, {grp[i], grp[v]}});
      }
    }
  }
  sort(edges.begin(), edges.end());
  long long ans = (long long)r * (r - 1) / 2;
  for (j = 0, k = 0; j < (int)edges.size(); j = k) {
    while (k < (int)edges.size() && edges[j].first == edges[k].first) k++;
    int c1 = edges[j].first.first, c2 = edges[j].first.second;
    for (i = j; i < k; i++) {
      int u, v;
      tie(u, v) = edges[i].second;
      c[u] = c[v] = c[op(u)] = c[op(v)] = 0;
      g[u].clear();
      g[op(u)].clear();
      g[v].clear();
      g[op(v)].clear();
    }
    for (i = j; i < k; i++) {
      int u, v;
      tie(u, v) = edges[i].second;
      add(u, v);
      add(u, op(u));
      add(v, op(v));
    }
    bool flag = true;
    for (i = j; i < k; i++) {
      int u, v;
      tie(u, v) = edges[i].second;
      if (!c[u]) flag &= dfs(u, 1, false);
      if (!c[v]) flag &= dfs(v, 1, false);
    }
    if (!flag) ans--;
  }
  cout << ans;
  return 0;
}
