#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int n, m, k;
int c[500005 * 2], g[500005 * 2];
int used[500005 * 2], no[500005 * 2];
map<pair<int, int>, set<pair<int, int>>> mp;
vector<int> v[500005 * 2];
int cur;
void dfs(int now, int co, int gg) {
  used[now] = 1;
  g[now] = gg;
  for (int x : v[now]) {
    if (c[x] != co) continue;
    if (used[x]) {
      if (g[x] != (gg ^ 1)) no[co] = 1;
      continue;
    }
    dfs(x, co, gg ^ 1);
  }
}
bool ddfs(int now, int gg) {
  g[now] = gg;
  used[now] = cur;
  for (int x : v[now]) {
    if (used[x] == cur) {
      if (g[x] != (gg ^ 1)) return 0;
      continue;
    }
    if (!ddfs(x, gg ^ 1)) return 0;
  }
  return 1;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  cur = 0;
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      dfs(i, c[i], cur);
      cur += 2;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int x : v[i]) {
      if (c[i] == c[x]) continue;
      mp[pair<int, int>(min(c[i], c[x]), max(c[i], c[x]))].insert(
          pair<int, int>(g[i], g[x]));
      mp[pair<int, int>(min(c[i], c[x]), max(c[i], c[x]))].insert(
          pair<int, int>(g[x], g[i]));
    }
  }
  for (int i = 1; i <= n; i++) {
    v[i].clear();
  }
  int cnt = 0;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    if (no[it->first.first] || no[it->first.second]) continue;
    set<pair<int, int>> &a = it->second;
    set<int> s;
    for (pair<int, int> p : a) {
      s.insert(p.first);
      s.insert(p.second);
      v[p.first].push_back(p.second);
    }
    for (int x : s) v[x].push_back(x ^ 1);
    bool ok = 1;
    cur++;
    for (int x : s) {
      if (used[x] != cur) {
        if (!ddfs(x, 1)) {
          ok = 0;
          break;
        }
      }
    }
    if (!ok) cnt++;
    for (int x : s) v[x].clear();
  }
  int cnt_no = 0;
  for (int i = 1; i <= k; i++) {
    if (no[i]) cnt_no++;
  }
  k -= cnt_no;
  printf("%lld\n", (long long)k * (k - 1) / 2 - cnt);
  return 0;
}
