#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a << endl;
  err(++it, args...);
}
const int N = 1e5 + 9;
const long long int inf = 1e14 + 9;
long long int c[N];
long long int dp[N][2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (long long int i = (long long int)(1); i < (long long int)(n + 1); i++)
    cin >> c[i];
  string a = "0", b = "0";
  for (long long int i = (long long int)(1); i < (long long int)(n + 1); i++) {
    string s, s1;
    cin >> s;
    s1 = s;
    reverse((s1).begin(), (s1).end());
    dp[i][0] = min(((s1 >= a) ? dp[i - 1][1] : inf),
                   ((s1 >= b) ? dp[i - 1][0] : inf)) +
               c[i];
    dp[i][1] =
        min(((s >= a) ? dp[i - 1][1] : inf), ((s >= b) ? dp[i - 1][0] : inf));
    a = s, b = s1;
  }
  long long int ans = min(dp[n][1], dp[n][0]);
  if (ans == inf)
    cout << -1;
  else
    cout << ans;
  return 0;
}
