#include <bits/stdc++.h>
using namespace std;
int book[100005];
char s[100005], t[100005], s1[100005], s2[100005];
int main() {
  int n, l, f1, f2, f3, f4;
  long long a, b, c, d;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &book[i]);
  scanf("%s", s);
  l = strlen(s);
  for (int i = 0; i < l; i++) t[i] = s[l - i - 1];
  a = 0;
  b = book[0];
  for (int i = 1; i < n; i++) {
    f4 = f3 = f2 = f1 = 0;
    scanf("%s", s1);
    l = strlen(s1);
    for (int j = 0; j < l; j++) s2[j] = s1[l - j - 1];
    if (strcmp(s, s1) <= 0) {
      if (strcmp(t, s1) <= 0)
        c = min(a, b);
      else
        c = a;
      f1 = 1;
    } else if (strcmp(t, s1) <= 0) {
      c = b;
      f2 = 1;
    }
    if (strcmp(s, s2) <= 0) {
      if (strcmp(t, s2) <= 0)
        d = min(a + book[i], b + book[i]);
      else
        d = a + book[i];
      f3 = 1;
    } else if (strcmp(t, s2) <= 0) {
      d = b + book[i];
      f4 = 1;
    }
    if (!(f1 || f2 || f3 || f4)) {
      printf("-1");
      return 0;
    }
    if (f1 || f2) {
      strcpy(s, s1);
      a = c;
    } else {
      strcpy(s, s2);
      a = d;
    }
    if (f3 || f4) {
      strcpy(t, s2);
      b = d;
    } else {
      strcpy(t, s1);
      b = c;
    }
  }
  cout << min(a, b);
  return 0;
}
