#include <bits/stdc++.h>
using namespace std;
bool bip[500000 + 10], vis[2 * 500000 + 10], color[2 * 500000 + 10];
int group[500000 + 10], badlinks[500000 + 10], code[500000 + 10];
vector<int> v[2 * 500000 + 10];
map<pair<int, int>, vector<pair<int, int>>> mp;
void dfs_bip(int x, bool c, int z) {
  color[x] = c;
  vis[x] = true;
  code[x] = z + (int)c;
  for (int y : v[x]) {
    if (vis[y])
      bip[group[x]] = bip[group[x]] && (color[x] != color[y]);
    else
      dfs_bip(y, !c, z);
  }
}
bool dfs_comp_bip(int x, bool c) {
  color[x] = c;
  vis[x] = true;
  bool ok = true;
  for (int y : v[x]) {
    if (vis[y])
      ok = ok && (color[x] != color[y]);
    else
      ok = ok && dfs_comp_bip(y, !c);
  }
  int z = x + ((x & 1) ? +1 : -1);
  if (vis[z])
    ok = ok && (color[x] != color[z]);
  else
    ok = ok && dfs_comp_bip(z, !c);
  return ok;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1, x; i <= n; ++i) cin >> group[i];
  for (int i = 1; i <= k; ++i) bip[i] = true;
  while (m--) {
    int a, b;
    cin >> a >> b;
    if (group[a] == group[b]) {
      v[a].push_back(b);
      v[b].push_back(a);
    } else {
      mp[{group[a], group[b]}].push_back({a, b});
      mp[{group[b], group[a]}].push_back({b, a});
    }
  }
  for (int i = 1, z = 1; i <= n; ++i)
    if (!vis[i]) dfs_bip(i, 0, z), z += 2;
  int nonbip = 0;
  for (int i = 1; i <= k; ++i)
    if (!bip[i]) nonbip++;
  long long ans = 0;
  for (pair<pair<int, int>, vector<pair<int, int>>> p : mp) {
    if (bip[p.first.first] && bip[p.first.second]) {
      for (pair<int, int> link : p.second) {
        vis[code[link.first]] = vis[code[link.second]] = false;
        vis[code[link.first] - 1] = vis[code[link.second] - 1] = false;
        vis[code[link.first] + 1] = vis[code[link.second] + 1] = false;
        v[code[link.first]].clear();
        v[code[link.second]].clear();
        v[code[link.first] - 1].clear();
        v[code[link.second] - 1].clear();
        v[code[link.first] + 1].clear();
        v[code[link.second] + 1].clear();
      }
      for (pair<int, int> link : p.second) {
        v[code[link.first]].push_back(code[link.second]);
        v[code[link.second]].push_back(code[link.first]);
      }
      bool ok = true;
      for (pair<int, int> link : p.second)
        if (!vis[code[link.first]])
          ok = ok && dfs_comp_bip(code[link.first], 0);
      if (!ok) badlinks[p.first.first]++;
    }
  }
  for (int i = 1; i <= k; ++i)
    if (bip[i]) ans += 1LL * (k - 1 - nonbip - badlinks[i]);
  cout << ans / 2 << endl;
  return 0;
}
