#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  long long i, c[n], inf = 1e16;
  for (i = 0; i < n; i++) {
    scanf("%lld", &c[i]);
  }
  string s[n], s1[n];
  for (i = 0; i < n; i++) {
    cin >> s[i];
    s1[i] = s[i];
    reverse(s1[i].begin(), s1[i].end());
  }
  long long dp[n][2];
  dp[0][0] = 0;
  dp[0][1] = c[0];
  for (i = 1; i < n; i++) {
    dp[i][1] = inf;
    dp[i][0] = inf;
    if (s[i] >= s[i - 1]) dp[i][0] = min(dp[i - 1][0], dp[i][0]);
    if (s[i] >= s1[i - 1]) dp[i][0] = min(dp[i][0], dp[i - 1][1]);
    if (s1[i] >= s[i - 1]) dp[i][1] = min(dp[i - 1][0] + c[i], dp[i][1]);
    if (s1[i] >= s1[i - 1]) dp[i][1] = min(dp[i - 1][1] + c[i], dp[i][1]);
  }
  long long ans = min(dp[n - 1][1], dp[n - 1][0]);
  if (ans >= inf)
    printf("-1\n");
  else
    printf("%lld\n", ans);
  return 0;
}
