#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> standardCycle = {0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
                               10, 11, 12, 13, 14, 15, 14, 13, 12, 11,
                               10, 9,  8,  7,  6,  5,  4,  3,  2,  1};
  int n;
  cin >> n;
  vector<int> pattern(n);
  for (long long int i = 0; i < n; i++) {
    cin >> pattern[i];
  }
  vector<int> patternPos;
  for (int i = 0; i < standardCycle.size(); i++) {
    bool valid = true;
    for (long long int j = 0; j < n; j++) {
      if (pattern[j] != standardCycle[(i + j) % standardCycle.size()]) {
        valid = false;
        break;
      }
    }
    if (valid) {
      patternPos.push_back(i);
    }
  };
  set<pair<long long int, long long int> > possibleNext;
  for (int d : patternPos) {
    int next = standardCycle[(d + pattern.size()) % standardCycle.size()];
    int prev = standardCycle[(d + pattern.size() - 1) % standardCycle.size()];
    possibleNext.insert(make_pair(next, prev));
  }
  if (possibleNext.size() == 1) {
    int nextIs = possibleNext.begin()->first;
    int prevIs = possibleNext.begin()->second;
    if (prevIs < nextIs) {
      cout << "UP";
    } else {
      cout << "DOWN";
    }
  } else {
    cout << -1;
  }
}
